Advertisement
alexandre-c

classeConexao

Nov 2nd, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package br.com.imobiliaria.model;
  2.  
  3. import java.sql.*;
  4.  
  5. /**
  6.  *
  7.  * @author alexandre
  8.  */
  9. public class ModuloConexao {
  10.  
  11.     public static Connection conector() throws SQLClientInfoException {
  12.         String server = "172.17.0.2", sql;
  13.         String port = "1521";               // Porta TCP padrão do Oracle
  14.         //String database = "imobiliaria";
  15.  
  16.         // Configuração dos parâmetros de autenticação
  17.         String user = "imobiliaria";
  18.         String passwd = "imob2019";
  19.  
  20.         try {
  21.             Class.forName("oracle.jdbc.driver.OracleDriver");
  22.             String url = "jdbc:oracle:thin:@" + server + ":" + port + ":" + "xe";
  23.  
  24.             // Abre-se a conexão com o Banco de Dados
  25.             Connection con = DriverManager.getConnection(url, user, passwd);
  26.             return con;
  27.         } catch (Exception e) {
  28.             e.printStackTrace();
  29.         }
  30.         return null;
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement