WebSphere interview question · Most asked
How do you configure a JDBC data source and connection pool in Liberty and in traditional WAS?
How you'd do it
Summary
In Liberty, add the jdbc feature, a <library> pointing at the driver JAR, and a <dataSource> with a JNDI
name, properties and a <connectionManager> for pool settings. In traditional WAS, create a JDBC provider
(driver and implementation class), a data source with a JNDI name and a J2C authentication alias for
credentials, then tune the connection pool (min/max connections, connection timeout, purge policy) and test
the connection.
Longer Answer
<featureManager><feature>jdbc-4.3</feature></featureManager>
<library id="pgLib"><fileset dir="${shared.resource.dir}/jdbc" includes="postgresql-*.jar"/></library>
<dataSource id="ordersDS" jndiName="jdbc/orders">
<jdbcDriver libraryRef="pgLib"/>
<properties.postgresql serverName="${db.host}" portNumber="5432" databaseName="orders"
user="${db.user}" password="${db.password}"/>
<connectionManager maxPoolSize="30" minPoolSize="5" connectionTimeout="10s" maxIdleTime="10m"/>
</dataSource>
Size the pool against the database's connection limit across all servers, keep credentials out of the file (environment variables or encoded/secret-backed variables), and set a connection timeout so requests fail fast.
Key Points
- Liberty: jdbc feature, library, dataSource, connectionManager.
- Traditional: JDBC provider, data source, J2C alias.
- Pool size × servers ≤ database limit.
- Credentials outside the config file.
Explanation
What interviewers look for
Practical configuration on both runtimes and sensible pool sizing.
More WebSphere questions
- How would you migrate an application from traditional WebSphere to Liberty?
- What is WebSphere Application Server, and how do Liberty and traditional WAS differ?
- How does Liberty's server.xml and feature model work?
- Explain the traditional WebSphere Network Deployment architecture: cell, Deployment Manager, nodes, node agents, servers and clusters.
- Explain class loading in WebSphere: parent-first versus parent-last, and shared libraries.
- Users see errors and the logs show J2CA0045E: connection not available. How do you investigate?
- WSVR0605W hung thread warnings appear and the application stops responding. What do you do?
- What is JNDI, and how do applications look up resources in WebSphere?