This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
Similar Threads
connecting to a database using Applets
error: no interface is connected
Beginner needs help
example of jdbc
Access to the Oracle database using Java Applets