• 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 with MS Access using Microsoft SDK

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ???
 
look! it's a bird! it's a plane! It's .... a teeny tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic