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.od bc.JdbcOdb cDriver"). newInstanc e();
Connection con = DriverManager.getConnectio n("jdbc:od bc:;DRIVER =Microsoft Access Driver(*.mdb);DBQ=F:/Ravi/ JDBC/Acces s/jdbc1.md b","","");
System.out.print(con);
System.out.print("Connecti on 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
}
}
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.od
Connection con = DriverManager.getConnectio
System.out.print(con);
System.out.print("Connecti
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Check the docs. Make sure that particular driver supports dsn-less. Try forward slashes.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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
ASKER