| Author |
How to connect Driver
|
eric lee
Ranch Hand
Joined: Nov 04, 2002
Posts: 86
|
|
When i run java Test,it shows error message, how can i solve it? Thanks. ----------------------------------------------- java.sql.SQLException[Microsoft] [ODBC Driver Manager]Data source name not found and no default driver specified ------------------------------------------------ import java.sql.*; public class Marking{ public static void main(String[] args) { // Load the driver try { // Load the driver class Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Define the data source for the driver String sourceURL = "jdbc dbc:bookbase"; // Create a connection through the DriverManager Connection databaseConnection = DriverManager.getConnection(sourceURL); // We made it! System.out.println("Connection established successfully!"); // close connection databaseConnection.close(); } catch (ClassNotFoundException cnfe) { System.err.println(cnfe); } catch (SQLException sqle) { System.err.println(sqle); } } }
|
 |
kishor rao
Ranch Hand
Joined: Dec 10, 2002
Posts: 35
|
|
I changed the datasource name to one I have on my system and it compiled and executed without any glitches. Make sure you have set up the ODBC connection properly.
|
 |
kishor rao
Ranch Hand
Joined: Dec 10, 2002
Posts: 35
|
|
|
If you have run the program as java test...thats wrong. I dont know where the test class is. You should run it as java Marking.
|
 |
 |
|
|
subject: How to connect Driver
|
|
|