public static void main (String args[])
throws SQLException, IOException {
System.out.println("Loading JDBC-ODBC driver");
try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception e) {e.toString();}
System.out.println("Connecting to Order database");
String url = "jdbc:odbc:OrdersDriver";
Connection gmrConn = DriverManager.getConnection(url);
System.out.println("After db connection");
gmrConn.close();
The System DSN is named OrdersDriver in the ODBC Driver manager. I have
also tried a File DSN named OrdersDriver in the same directory as the java
class. I have tested both with a VB app and they are working as ODBC DSNs.
I get the following program output:
Loading JDBC-ODBC driver
Connecting to Order database
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver
Manage
r] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at BuildJDBC.main(BuildJDBC.java:17)
Is there some special configuration that must be done to get the jdbc:odbc
driver to work on Windows? Any information will be greatly appreciated.
Thank you.