aspose file tools
The moose likes JDBC and the fly likes Problem in connecting to DB2 using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Problem in connecting to DB2 using JDBC" Watch "Problem in connecting to DB2 using JDBC" New topic
Author

Problem in connecting to DB2 using JDBC

sirisha alam
Greenhorn

Joined: Dec 17, 2002
Posts: 13
I am trying to connect to DB2 database from java and am getting the fllowing error.
java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
I have set the required classpath. And here is the code that i am trying to use:
import java.io.*;
import java.sql.*;
public class SingleDBConnect
{
static SingleDBConnect dbConnection = null;
private Connection con = null;

private SingleDBConnect()
{
try
{
Class.forName("com.ibm.db2.jcc.DB2Driver");
con = DriverManager.getConnection("jdbc b2:univ", "db2admin", "db2admin");
}
catch(ClassNotFoundException ex)
{
System.out.println("Exception in SingleDBConnect : " + ex);
}
catch(SQLException ex)
{
System.out.println("SQLException : " + ex);
}
}
public static Connection getConnection()
{
if( dbConnection == null )
{
dbConnection = new SingleDBConnect();
}
return dbConnection.con;
}
}
Please advise me on this.
Jan Modaal
Greenhorn

Joined: Apr 06, 2004
Posts: 4
what happens if you place on top:
import com.ibm.db2.jcc.DB2Driver;
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem in connecting to DB2 using JDBC
 
Similar Threads
Hibernate DB2
java.sql.SQLException: No suitable driver
Problem in JDBC connection in Websphere 3.5.0
jdbc program written in Eclipse3.2.1 to connect DB2
InvalidAlgorithmParameterException