0
votes

I deployed WAR file on Websphere console and mapped it to datasource. I am able to test the datasource which I configured with PostgreSQL server details. But my application is not connecting to the server. I am new to WebSphere and could anyone please help me to configure the datasource based on the below context.xml file. My application works well in tomcat but not in Websphere.

I think am doing something wrong in the datasource configuration.

<Resource 
    name="jdbc/domains/ABC" url="jdbc:postgresql://localhost:5432/postgres"
    initConnectionSqls="SET search_path TO my_schme;"
    username="abccc"
    password="******"              
    auth="Container" 
    type="javax.sql.DataSource" 
    driverClassName="org.postgresql.Driver"
    validationQuery="select 1"
    initialSize="5" 
    maxActive="20" 
    maxIdle="10"
    maxWait="-1"
/>
1
I am getting 503 error with a status "Server status: Loading..." - Arul Rajasekaran
WebSphere traditional or Liberty? - F Rowe

1 Answers

0
votes

Here is an example based on the most common way to configure data sources in WebSphere Application Server Liberty -- in server.xml (it is also possible to define within the application via the standard @DataSourceDefinition annotation or deployment descriptor, which would be a separate example)

In server.xml,

<featureManager>
  <feature>jdbc-4.2</feature>
  <feature>jndi-1.0</feature>
  ... other features
</featureManager>

<dataSource id="ABC" jndiName="jdbc/domains/ABC" type="javax.sql.ConnectionPoolDataSource" validationTimeout="30s">
    <jdbcDriver libraryRef="PostGreLib" javax.sql.ConnectionPoolDataSource="org.postgresql.ds.PGConnectionPoolDataSource"/>
    <properties url="jdbc:postgresql://localhost:5432/postgres"/>
    <containerAuthData user="abccc" password="******"/>
    <connectionManager maxPoolSize="20" connectionTimeout="-1"/>
    <!-- no equivalents for initialSize and maxIdle -->
    <onConnect>SET search_path TO my_schme;</onConnect>
</dataSource>

<library id="PostGreLib">
    <file name="C:/PostGreSQL/postgresql-42.1.4.jar"/>
</library>

Here are some helpful knowledge center articles on data source configuration in WebSphere Application Server Liberty,

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_configuring_ds.html

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.liberty.autogen.base.doc/ae/rwlp_feature_jdbc-4.2.html