• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classnotfoundexception

 
satya narayan reddy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
can anybody please fix why the below program is giving classnotfoundexception

thanks in advance,
satya

import java.sql.*;
import java.io.*;
public class JDBCTest
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JDbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc dbc:venkatdsn");
Statement st = c.createStatement();
ResultSet rs =st.executeQuery("Select sno,sname from student");
try
{
while(rs.next())
{
System.out.println(rs.getInt("sno")+":");
System.out.println(rs.getString("sname"));
}
}
catch(Exception e)
{
System.out.println("inside:"+e);
}
}
catch(Exception e)
{
System.out.println(e);
}

}


}


Runtime Exception:
--------------------
java.lang.ClassNotFoundException:sun.jdbc.odbc.JDbcOdbcDriver
 
trinadh reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
give the classname as
sun.jdbc.odbc.JdbcOdbcDriver
 
sailesh sirari
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi


Class.forName("sun.jdbc.odbc.JDbcOdbcDriver");


this line should be

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

be careful for typos as it will not give error

Cheers!

Sailesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic