I am trying to run a book example from Beginning Java 2 on the JDBC chapter and I am having trouble getting the example to run. I am using the downloaded database and example. I set up the Data Source Name in the ODBC Microsoft Access setup (Access 2000, on win 98), and the classpath contains the rt.jar. The database is ok, I can open it and look at the tables. What
needs to be included or changed for me to get this to work? Thanks.
import java.sql.*;
public class TestTheConnection
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL = "jdbc
dbc:technical_library";
Driver theDriver = DriverManager.getDriver(sourceURL);
int verMajor = theDriver.getMajorVersion();
float verComplete = Float.parseFloat(verMajor + "" + theDriver.getMinorVersion());
System.out.println("sourceURL version: " + verComplete);
Connection databaseConnection =
DriverManager.getConnection(sourceURL);
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.out.println("SQLException: " + sqle.getMessage());
sqle.printStackTrace();
}
}
}
sourceURL version: 21.0
SQLException: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path.
Make sure that the path name is spelled correctly and that you are connected to the server on
which the file resides.
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path.
Make sure that the path name is spelled correctly and that you are connected to the server on which
the file resides.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2458)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:320)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:163)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:199)
at TestTheConnection.main(TestTheConnection.java:22)