Program written below gives error with Microsoft SDK when connecting MS Access but working perfectly when using Sun JDK. Error it gives is :- java.lang.NoClassDefFoundError Using same code for Microsoft SDK and Sun SDK customer: DSN Name class test { public static void main(String args[]) { Connection c=null; Statement st=null; ResultSet rs=null; try { // For Connecting with MS-Access System.out.println("1111"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); System.out.println("222"); c=DriverManager.getConnection("jdbc dbc:customer"); System.out.println("333"); st=c.createStatement(); String query="select count(*) as count from rainbowcustomers"; rs=st.executeQuery(query); while(rs.next()) { int count=rs.getInt("count"); System.out.println(count); } } catch(NoClassDefFoundError e) { System.out.println(e); } catch(Exception e) { System.out.println(e); } } } Gives error after printing 111 222. This means error is at c=DriverManager.getConnection("jdbc dbc:customer"); Couldn't solve it. Pls somebody help. Thanks
while(rs.next()) { int count=rs.getInt("count"); System.out.println(count); }
sometimes even though you rename the column to count, the driver cannot see this. Try changing the column name "count" to absolute position 1 in the getInt() method:
while(rs.next()) { int count=rs.getInt(1); System.out.println(count); }
Jamie
hasan wasif2k1
Greenhorn
Joined: Jan 13, 2001
Posts: 26
posted
0
But the program doesn't even reach there as it does not print 333 which is after c=DriverManager.getConnection("jdbc dbc:customer"); System.out.println("333"); The problem is only at c=DriverManager.getConnection("jdbc dbc:customer"); and that too working perfectly with Sun SDK but not when executing in VJ++ or Microsoft SDK ???
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 with MS Access using Microsoft SDK