Im trying to establish my connection, and I'm getting an sql exception..The error message is: sqlException data source name not found and no default driver specified. I got this code straight out of book. The book is based on 1.4, and I have 1.5, so I don't know if that might have something to do with the default driver.
Code:import java.sql.*; public class JDBCConnection2 { /** Default Constructor */ public JDBCConnection2() { } public static void main(String[] args) { try { // Use the standard bridge driver packaged with the jdk Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Specify the ODBC data soure name you want to use String sourceURL = "jdbc:odbc:TicketRequest"; //get a connection to the database // obtain an instance of the class Connection Connection databaseConnection = DriverManager.getConnection(sourceURL); // IF we get to here, no exceptions was thrown System.out.println("The database connection is " + databaseConnection); } catch (ClassNotFoundException cnfe) { System.err.println(cnfe); } catch(SQLException sqle) { System.err.println(sqle); } } }




Reply With Quote