我将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>
答案 0 :(得分:3)
我必须将URL属性添加到glass fish admin并将其设置为&#34; jdbc:mysql://:3306 / clearsoft_demo&#34;并且还进入MySQL并为root @ localhost授予权限。
答案 1 :(得分:1)
只需更改Java.inc
它会正常工作