Acquiring a DataSource connection to a database

Using the DataSource interface, the connection to the database is obtained with a Java Naming and Directory Interface (JNDI) DataSource name lookup. JDBC DataSource implementation is provided by the CICS® JDBC feature in Liberty.

About this task

A DataSource connection is configured in a Liberty JVM server with the CICS JDBC Liberty feature.

After the DataSource is configured, the application can use the use the value of the jndiName specified in the cicsts_dataSource element in the Liberty server configuration to obtain an instance of that DataSource class from the JNDI naming service. The getConnection() method can then be called on that DataSource object to get a connection. For example:
Context context = new InitialContext();
DataSource dataSource = (DataSource)
context.lookup("jdbc/defaultCICSDataSource");

Connection connection = dataSource.getConnection();


dfhtk7w.html | Timestamp icon Last updated: Monday, 5 June 2017