Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

/* 
 * */
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);
        }
    }
}