Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC Connection to DB2 PE

Status
Not open for further replies.

Chikea

Programmer
Sep 9, 2004
3
DE
Hello,
I'm a newbie in struts and have the following problem:
i want to connect to a local DB2 Personal Edition Database. but everytime i get a ClassNotFoundException by running the code in a Model Bean:

import java.sql.*;

public boolean checkLogin(String user, String password)
throws SQLException
{

try
{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");

Connection my_con = DriverManager.getConnection("jdbc:db2:MyDB",
user , password);

return true;
}

catch (ClassNotFoundException e)
{
return false;
}

catch (SQLException se)
{
return false;
}



}

I know that datasourses should be declared in struts-config.xml. but this should not influence this code fragment. I'm very confused, because i use the same (!!!) code in a simple java application. there everything's well...what must i do to run this code under struts and tomcat???must i declare the datasourses in the struts-config.xml???

Thanx!!!
Chikea
 
Hi,

Copy the driver .jar file into the WEB-INF/lib dir or in the Classpath of tomcat. It is not able to load the driver.

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top