Guest User

Untitled

a guest
Sep 4th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package conexao;
  2.  
  3. import java.sql.*;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6.  
  7. public class Conexao {
  8.  
  9.     private Connection conexao = null;
  10.     private Statement st;
  11.     private PreparedStatement ps;
  12.  
  13.    
  14.     public Connection getConexao() throws Exception{
  15.        
  16.      try{
  17.        
  18.         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  19.         conexao = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","ufpe3","123456");
  20.         st = conexao.createStatement();
  21.        
  22.         return conexao;
  23.        
  24.       }catch (Exception e){
  25.            
  26.          throw new Exception("Ocorreu um erro na conexao do drive do servidor de banco de dados.");
  27.  
  28.         }
  29.     }
  30.        
  31.    
  32.     public Statement getStatement(){
  33.  
  34.         return st;
  35.  
  36.     }
  37.  
  38.     public PreparedStatement getPreparedStatement(){
  39.  
  40.         return ps;
  41.  
  42.     }
  43.        
  44. }
Add Comment
Please, Sign In to add comment