context.xml and DataSource
- From: "Aljosa Mohorovic" <aljosa.mohorovic@xxxxxxxxx>
- Date: 28 Nov 2006 09:06:38 -0800
i'm getting "Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'"
error but this code works:
working code:
String url = "jdbc:db2://localhost:50000/test";
String user = "user";
String password = "pass";
Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection conn = DriverManager.getConnection(url, user, password);
<<<
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Test">
<Resource name="test"
auth="Container"
type="javax.sql.DataSource"
username="user"
password="pass"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://localhost:50000/test"
/>
</Context>
<<<
code not working:
InitialContext ic = new InitialContext();
Context c = (Context)ic.lookup("java:comp/env");
try {
DataSource ds = (DataSource)c.lookup("test");
Connection connection = ds.getConnection();
} catch(Exception e) {
// log e.getMessage();
}
<<<
.
- Prev by Date: Re: Giving an application a window icon in a sensible way
- Next by Date: Re: Can't send email from J2ME.
- Previous by thread: Why is Java lying?
- Next by thread: SOS trying to make work sun JSSE within IBM jdk.
- Index(es):
Relevant Pages
|