|
jdbc.odbc.jdbcodbc error
|
Posted: May 17, 2002 12:39 AM
|
|
Advertisement
|
whenever in my code cntrl comes to
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
it gives out error,
below is my sample code import java.sql.*; //import sun.jdbc.odbc.*; import java.util.*; class sql1 { public static void main(String args[]) throws ClassNotFoundException { String slno, ques, ans; Connection con; Statement stmt; //ResultSet rs;
try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); java.sql.DriverManager.setLogStream(java.lang.System.out);
java.sql.Connection c = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=samp.mdb;PWD=mypass","user","pass"); java.sql.Statement st = c.createStatement(); java.sql.ResultSet rs = st.executeQuery("select * from samp");
//con=DriverManager.getConnection("jdbc:odbc:Wildtangent"); //stmt = con.createStatement(); //rs = stmt.executeQuery("SELECT * from samp"); while (rs.next()) { slno=rs.getString(0); ques=rs.getString(1); ans=rs.getString(2); System.out.println(slno); System.out.println(ques); System.out.println(ans); } } catch(Exception e) { System.out.println("catch"); System.err.println(e.getMessage()); } } }
please help me out
|
|