What Can Cause Glassfish / JDBC Error "No Database Selected"

I am using Glassfish 4 with Java EE 7 and MySQL 5.6.2.

Here is the error:

org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Database not selected Error code: 1046

Here is glassfish-resources.xml:

<resources>
  <jdbc-resource enabled="true" jndi-name="jdbc/clearsoftDemo" object-type="user" pool-      name="clearsoftDemoPool">
    <description/>
  </jdbc-resource>
  <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="clearsoftDemoPool" non-transactional-connections="false" ping="false" pool-resize-quantity="2" pooling="true" res-type="javax.sql.DataSource" statement-cache-size="0" statement-leak-reclaim="false" statement-leak-timeout-in-seconds="0" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
    <property name="serverName" value="localhost"/>
    <property name="portNumber" value="3306"/>
    <property name="databaseName" value="clearsoft_demo"/>
    <property name="User" value="root"/>
    <property name="Password" value=""/>
    <property name="URL" value="jdbc:mysql://:3306/clearsoft_demo"/>
    <property name="driverClass" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/>
  </jdbc-connection-pool>
<!--<jdbc-resource enabled="true" jndi-name="jdbc/clearsoftDemo" object-type="user" pool-name="clearsoftDemoPool"/>-->
</resources>

      

+3


source to share


2 answers


I had to add a URL property to the glassfish admin and set it to "jdbc: mysql: //: 3306 / clearsoft_demo" and also go to MySQL and grant root @localhost permissions.



+3


source


just change <property name="URL" value="jdbc:mysql://localhost:3306/clearsoft_demo"/>

it will work fine



+1


source







All Articles