数据库
首页 > 数据库> > mysql-什么可能导致此Glassfish / JDBC错误“未选择数据库”

mysql-什么可能导致此Glassfish / JDBC错误“未选择数据库”

作者:互联网

这个问题已经在这里有了答案:            >            Connect Java to a MySQL database                                    13个
我正在将Glassfish 4与Java EE 7和MySQL 5.6.2一起使用.

这是错误:

org.eclipse.persistence.exceptions.DatabaseException
内部异常:java.sql.SQLException:未选择数据库
错误代码:1046

这是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>

解决方法:

我必须将URL属性添加到glass fish admin并将其设置为“ jdbc:mysql://:3306 / clearsoft_demo”,还必须进入MySQL并授予root @ localhost的权限.

标签:glassfish-4,jdbc,glassfish,mysql,java-ee
来源: https://codeday.me/bug/20191029/1957834.html