import java.sql.*; import java.util.*; import java.io.*; public class ManagerConnectExt { public ManagerConnectExt () { try { // Create the driverName, URL, username, and password strings String driverName = "sun.jdbc.odbc.JdbcOdbcDriver"; // JDBC-ODBC Bridge driver String dbURL = "jdbc:odbc:fiaa"; String user = "p8cp1"; String pass = "ismael"; // Set the log stream for the manager // DriverManager.setLogStream(System.out); - Deprecated DriverManager.setLogWriter( new PrintWriter(System.out, true)); // 1.1 - Get the current system properties Properties sysPro = System.getProperties(); sysPro.put("jdbc.drivers", driverName); System.setProperties(sysPro); // 1.2 - Create the connection Connection c1 = DriverManager.getConnection(dbURL, user, pass); System.out.println("--- Conection 1 established ---"); // Another way of doing all this is just ... // 2.1 - Load the driver or drivers you want to use Class.forName(driverName); // You do not need to create an instance of a driver and // register it with the DriverManager because calling // Class.forName will do that for you automatically. // -> Driver driver = (Driver)Class.forName(driverName).newInstance(); // -> DriverManager.registerDriver(driver); // Esta parte eh equivalente aos passos 1.1 e 1.2 // 2.2 - Create the connection Connection c2 = DriverManager.getConnection(dbURL, user, pass); System.out.println("--- Conection 2 established ---"); // The connection returned by the method DriverManager.getConnection is // an open connection you can use to create JDBC statements that pass // your SQL statements to the DBMS. } catch (Exception e) { System.out.println(e.getMessage()); } } public static void main (String args[]) { ManagerConnectExt app = new ManagerConnectExt(); } }