Share this page 

Using DSN-less connectionTag(s): JDBC


This HowTo is deprecated. For Java 8 you cannot use the JDBC-ODBC Bridge because it has been removed.

This HowTo seems broken, if anyone know what is problem, let me know!, Thanks
(works on some Windows installation while on other it does not!)

It is possible to connect to a database without a User or System DSN. This is useful if you don't have easy access to a client registry to define the required DSN. Not all JDBC driver support this feature.

// For Access
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String myDB =
"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/data/month.MDB";
DBConn = DriverManager.getConnection(myDB,"","");

// For Excel
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String myDB =
   "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/data/month.xls;"
    + "DriverID=22;READONLY=false";
DriverManager.getConnection(myDB,"","");
Thanks to R. Hibberd for the tip.