A Techno Blog, mainly about Java

Junit and Java1.5 examples


October 22, 2004 Posted by | J2EE | Leave a comment

datasource in web.xml with JNDI

In the past I would establish a connection to a database like this:

Class.forName (Driver_string).newInstance ();
connection = DriverManager.getConnection (“jdbc:db2://localhost/qms”, user_name, “user_password”);

However, it is not a good idea to code such information in the application’s source code. They are all likely to change over time. Here on page 8 I learned you can use the web.xml to specify the datasource.

October 22, 2004 Posted by | J2EE | 11 Comments