Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to connect Driver

 
eric lee
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic