• 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

java.sql.SQLException: No suitable driver

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am trying to make DB2 connection but its throwing exception...Here is the code and output

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Test {

public static void main(String args[])

{
String url="jdbc:db2://localhost:50000/DWCTRLDB";
Connection con;
String query ="SELECT * FROM test.employee";
Statement stmt;
try{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("class not found: ");
System.err.println(e.getMessage());
}
try {

con= DriverManager.getConnection(url,"db2admin","db2admin");
System.out.println("got connection");
stmt =con.createStatement();
ResultSet result =stmt.executeQuery(query);
while (result.next()) {
String name = result.getString(1) +" "+
result.getString(2);
System.out.println(name);
}
stmt.close();
con.close();
}
catch(SQLException ex) {
System.err.print("SQLException:");
System.err.println(ex.getMessage());
ex.printStackTrace();
}

}
}

The output is:
SQLException:No suitable driver
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:559)
at java.sql.DriverManager.getConnection(DriverManager.java:189)

I am using RAD6.0. I added jdbc drivers to java build path.
db2java.zip
db2jcc.jar
db2jcc_license_cu.jar
db2jcc_license_cisuz.jar

I configured same jars,Dburl,username,password on DbVisualizer, its working fine.So i think there is no problem with url,username and password.(I am sure).
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whish jar has the class COM.ibm.db2.jdbc.app.DB2Driver ?? Check that this class/jar is in the classpath.
 
prajwala solanki
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
db2java.zip
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic