Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public Connection getConexionBD(String bd) {
  2. System.out.println("en la clase conexionJDBC");
  3. String driver="";
  4. String connectString="";
  5. String user="";
  6. String password="";
  7.  
  8. if(bd.equals("postgresql")){
  9. driver="org.postgresql.Driver";
  10. connectString="jdbc:postgresql://10.34.2.62:5432/GestionGarita";
  11. user="postgres";
  12. password="portalprodpostgres64";
  13. }
  14. if(bd.equals("sqlserver")){
  15. driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
  16. connectString="jdbc:sqlserver://10.34.2.83:1433;database=SincroBI;";
  17. user="USERSINCRO";
  18. password="sincrobi";
  19. }
  20. if(bd.equals("sqlserver_DWH_CPSAA")){
  21. driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
  22. connectString="jdbc:sqlserver://10.34.2.83:1433;database=DWH_CPSAA;";
  23. user="CPSAABI";
  24. password="cpsaabi";
  25. }
  26.  
  27. Connection cn = null;
  28. try {
  29. Class.forName(driver);
  30. cn = DriverManager.getConnection(connectString, user, password);
  31. } catch (Exception e) {
  32. System.out.print("conexion incorrecta");
  33. System.out.println(e.getMessage());
  34. e.printStackTrace();
  35. }
  36. return cn;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement