java program to connect to a datasaource in WAS 5.0.2
Posted on 2004-10-29
I have DB2 8.1 and create a database, ARRT, with 2 tables.
The datasource that i have configured in WAS 5.0.2 connects to the database fine, as the test connection works successfully. The datasource uses the DB2 JDBC DRIVER.
I have a java program that needs to connect to the datasource and extract some information that can be displayed on a browser through a jsp. To create the connection to the datasource I used the following code
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/ARRT");
con = ds.getConnection();
but it didnt work. Is there something I am missing or is there a simpler way to do this.
Help will be greatly appreciated