aspose file tools*
The moose likes JDBC and the fly likes Problem with MS Access using Microsoft SDK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with MS Access using Microsoft SDK" Watch "Problem with MS Access using Microsoft SDK" New topic
Author

Problem with MS Access using Microsoft SDK

hasan wasif2k1
Greenhorn

Joined: Jan 13, 2001
Posts: 26
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
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879


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
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://aspose.com/file-tools
 
subject: Problem with MS Access using Microsoft SDK