Engenharia civil
public class Conexao {
private Connection con; private Statement st; private ResultSet rs = null;
public Conexao() { }
/* CONEXÃO COM ACCESS */
public int fazerConexao() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=E:\\Controle.mdb", "", ""); st = con.createStatement(); return 1; } catch (ClassNotFoundException ex) { return 0; } catch (SQLException ex1) { return 0; }
}
/* CONEXÃO COM MYSQL
public int fazerConexao() { try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/controle", "root", "teruel"); st = con.createStatement(); return 1; } catch (ClassNotFoundException ex) { return 0; } catch (Exception ex1) { return 0; } } */
/* CONEXÃO COM SQLSERVER - NECESSÁRIO DRIVER BAIXADO DO SITE DA MICROSOFT (sqljdbc.JAR)
public int fazerConexao() { try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // Abrindo a conexão com o servidor TERUEL, login sa e sem senha con = DriverManager.getConnection("jdbc:microsoft:sqlserver://TERUEL:1433","sa",""); st = con.createStatement(); return 1; } catch (ClassNotFoundException ex) { return 0; } catch (Exception ex1) { return 0; } } */
/* CONEXÃO COM ORACLE - NECESSÁRIO DRIVER BAIXADO DO SITE DA ORACLE (ojdbc14.JAR)
public int fazerConexao() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); con = DriverManager.getConnection("jdbc:oracle:thin:@ 127.0.0.1:1521:XE","system","123"); st = con.createStatement();