aspose file tools*
The moose likes JDBC and the fly likes How to connect Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to connect Driver" Watch "How to connect Driver" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to connect Driver