我正试图让db2在glassfish中工作而根本没有运气。我已经阅读了文档,但无论我做什么,当我执行ping操作时最终都会遇到错误。我将db2驱动程序和连接的jar文件放在类路径前缀中,将它们添加到域的lib目录中,然后不再使用。我究竟做错了什么?谢谢你的时间。
答案 0 :(得分:0)
您没有提及有关数据源创建的任何信息。你有没有创建数据源?
以下是如何在域的conf目录中的domain.xml文件中创建一个。
<jdbc-resource enabled="true" jndi-name="jdbc/<YOUR_DS_NAME_HERE>" object-type="user" pool-name="<YOUR_POOL_NAME_HERE>">
<description><DESCRIPTION></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.ibm.db2.jcc.DB2ConnectionPoolDataSource" fail-all-connections="true" idle-timeout-in-seconds="140" is-connection-validation-required="true" is-isolation-level-guaranteed="false" 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="YOUR_POOL_NAME_HERE>" non-transactional-connections="false" pool-resize-quantity="32" res-type="javax.sql.ConnectionPoolDataSource" statement-timeout-in-seconds="-1" steady-pool-size="0" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<description><YOUR_POOL_NAME_HERE_DESCRIPTION></description>
<property name="user" value="<USERNAME>"/>
<property name="password" value="<PASSWORD>"/>
<property name="portNumber" value="<PORTNUMBER>"
<property name="databaseName" value="DATABASE_NAME"/>
<property name="serverName" value="<SERVER_NAME>"/>
<property name="driverType" value="4"/>
</jdbc-connection-pool>
您也可以复制$ GLASSFISH_HOME / lib目录中的jar文件。