This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to connect Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to connect Driver
 
Similar Threads
database connectivity
Connection Problem
Classpath issues
JList Problem
JDBC and JApplet