Advertisement
wellviana

Untitled

Nov 28th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.sql.*;
  2. public abstract class Conectar {
  3.     public static String status="";
  4.    
  5.     public static Connection getConnection() {
  6.         Connection cn = null;
  7.         try{
  8.             String banco   = "bd113632013";
  9.             String url     = "jdbc:jtds:sqlserver://10.4.0.89:1433/" + banco;
  10.             String usuario = "bd113632013";
  11.             String senha   = "123456";
  12.            
  13.             Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
  14.             cn = DriverManager.getConnection( url ,usuario , senha);
  15.            
  16.             status = "Conexão Aberta";
  17.         }catch(SQLException e){
  18.             status =  e.getMessage();
  19.         }catch(ClassNotFoundException e){
  20.             status =  e.getMessage();
  21.         }catch(Exception e){
  22.             status =  e.getMessage();
  23.         }
  24.         return cn;
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement