DriverManager: getConnection(String url) (jdbc:odbc:technical_library) : DriverManager « java.sql « Java by API






DriverManager: getConnection(String url) (jdbc:odbc:technical_library)

 
/* 
 * */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
  public static void main(String[] args) throws Exception {
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

      // Define the data source for the driver
      String sourceURL = "jdbc:odbc:technical_library";

      // Create a connection through the DriverManager 
      Connection databaseConnection = DriverManager.getConnection(sourceURL);
      System.out.println("Connection is: "+databaseConnection);
    } catch(ClassNotFoundException cnfe) {
      System.err.println(cnfe);
    } catch(SQLException sqle) {
      System.err.println(sqle);
    }
  }
}

           
         
  








Related examples in the same category

1.DriverManager: getConnection(String url, String user, String password)
2.DriverManager: getConnection(String url, Properties info)
3.DriverManager: getDrivers()
4.DriverManager: registerDriver(Driver driver)
5.DriverManager: setLogWriter(PrintWriter out)