Link to home
Start Free TrialLog in
Avatar of ravi_patankar
ravi_patankar

asked on

JDBC MS Acess connect DSN-less free

I have jdk1.3 (installed from j2sdk1_3_0-win.exe) on Windows XP machine with office 2000 installed.
The Driver, present on system is Microsoft Access Driver (*.mdb) 4.00.6019.00

After compiling the code successfully, an exception is thrown as follows while running the class file:
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Code is as follows:

import java.sql.*;
import java.io.DataInputStream;
import java.awt.*;

public class test
{
     public static void main(String args[]) throws Exception
     {
          //String url = "JDBC:ODBC:MySQLDSN";
          Statement stmt;
          // Attempt to load database driver
        try
             {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                Connection con = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver(*.mdb);DBQ=F:/Ravi/JDBC/Access/jdbc1.mdb","","");
                System.out.print(con);
                System.out.print("Connection done");
             }
           catch (ClassNotFoundException cnfe) // driver not found
             {
                System.err.println ("Unable to load database driver");
                System.err.println ("Details : " + cnfe);
                System.exit(0);
             }

          // Create a URL that identifies database
          // Here MySQLDSN is DSN
         
           
     }

}
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ravi_patankar
ravi_patankar

ASKER

Dear CEHJ: Thanks for the quick reply but same exception is thrown after applying the code change suggested by you.
Check the docs. Make sure that particular driver supports dsn-less. Try forward slashes.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ravi_patankar:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between CEHJ and objects

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer