我有应用程序运行在Websphere Liberty和使用DB2在ZoS。我已经设置了db2驱动程序proerties在DB2JCCConfiguration.properties.如何能确保服务器已经拿起属性,我已经设置了。
要用Liberty配置一个数据源(针对任何后端DB),你可以在你的server.xml中添加这样的配置。
<featureManager>
<feature>jdbc-4.2</feature>
</featureManager>
<library id="driver-library">
<fileset dir="/path/to/driver/dir" includes="*.jar"/>
</library>
<dataSource id="DefaultDataSource" jndiName="jdbc/myDB">
<jdbcDriver libraryRef="driver-library"/>
<properties.db2.jcc serverName="example.db.hostname.com" portNumber="50000"
databaseName="myDB"
user="exampleUser"
password="examplePassword"
currentSchema="xyz"
fullyMaterializeInputStreams="true"/>
</dataSource>
为了测试你的配置是否正确 以及你的Liberty服务器是否能连接到你的DB2数据库 添加以下配置:
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>restConnector-2.0</feature>
<feature>jdbc-4.2</feature>
</featureManager>
<!-- Any security mechanism can be used, <quickStartSecurity> is the simplest -->
<quickStartSecurity userName="admin" userPassword="admin"/>
然后进入: https:/localhost:9443ibmapivalidationdataSourceDefaultDataSource。(这是假设你的 <dataSource>
id
是 DefaultDataSource
)
更多信息,请看这个攻略。https:/aguibert.github.ioopenliberty-cheat-sheet#_ibm_db2。