• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in connecting to DB2 using JDBC

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what happens if you place on top:
import com.ibm.db2.jcc.DB2Driver;
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic