我正在開發一個包含JAR和WAR文件的EAR文件的簡單Java EE應用程序。在根據EarContent/META-INF的EAR項目,我有以下的GlassFish-resources.xml中:爲什麼不創建一個jdbc連接池?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool name="java:app/jdbc/test" res-type="javax.sql.XADataSource" datasource-classname="org.apache.derby.jdbc.ClientXADataSource">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="1527"/>
<property name="databaseName" value="test"/>
<property name="createDatabase" value="create"/>
<property name="user" value="APP"/>
<property name="password" value="APP"/>
</jdbc-connection-pool>
<jdbc-resource jndi-name="java:app/jdbc/test" pool-name="java:app/jdbc/test"/>
</resources>
在根據META-INF的EJB項目,我有以下的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="events" transaction-type="JTA">
<description>Manages events, users and comments</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:app/jdbc/test</jta-data-source>
<class>com.hank.entity.Question</class>
<class>com.hank.entity.QuizWalk</class>
<class>com.hank.entity.User</class>
<class>com.hank.entity.QuizWalkParticipants</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.logging.connection" value="false"/>
<property name="eclipselink.logging.level.sql" value="ALL"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.session" value="false"/>
<property name="eclipselink.logging.thread" value="false"/>
<property name="eclipselink.logging.timestamp" value="false"/>
</properties>
</persistence-unit>
</persistence>
我有一個運行的Derby服務器,端口號是正確的。應用程序正在工作,但沒有創建數據庫。什麼可能是錯誤的?這種方法適用於Glassfish 3.1。
漢克
你可以發佈你的stacktrace嗎? – Abdelhak
我沒有收到任何錯誤消息,因此沒有堆棧跟蹤。 – iHank