Menu

java.sql.SQLException: No database selected

Anonymous
2016-02-10
2016-09-02
  • Anonymous

    Anonymous - 2016-02-10

    Hello,

    I just started to use SQLeo, and I like it very much.

    I have a question when I copy an existing query, and paste it into the syntax-tab.

    When I want to run the query, I get the error:

    java.sql.SQLException: No database selected

    How can I select de database, because I opened and selected the correct database.
    I use MySQL (MariaDB Jdbc Driver)

    Thanks,
    Marc

     
    • PAscal

      PAscal - 2016-02-10

      Hello,

      with this driver if you don't specify the database in the URL like
      jdbc:mysql://localhost:3306

      then you have to préfix your table name with the schema or database name like:

      select MyTableAlias.blabla from MyDatabaseName.MyTable as MyTableAlias

      or to specifiy the database before to launch the select with syntax
      use MyDatabaseName

      Regards
      PAscal

       

      Last edit: PAscal 2016-02-10
      • PAscal

        PAscal - 2016-09-02

        to clarify MySQL set up:

        when using only one database / without prefixing table names
        URL jdbc:mysql://localhost:3306/dbname
        Preference: menu/tools/preferences/query builder: don't use schema name in syntax definition
        generated syntax: select ... from tablename

        when using many databases / prefixing table names with db name
        URL: jdbc:mysql://localhost:3306
        Preference: menu/tools/preferences/query builder: use schema name in syntax definition
        generated syntax: select ... from dbname.tablename

         

Anonymous
Anonymous

Add attachments
Cancel