Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import java.sql.DriverManager;
  2.  
  3. import com.mysql.jdbc.Connection;
  4.  
  5. public class Conexion
  6. {
  7. private static Connection conexion;
  8. private static final String driver="com.mysql.jdbc.Driver";
  9. private static final String usuario="eshos_19255445";
  10. private static final String password="miPass";
  11. private static final String url="jdbc:mysql://sql104.eshost.com.ar:3306/eshos_19255445_pruebaDB";
  12.  
  13. public Conexion()
  14. {
  15. conexion=null;
  16.  
  17. try
  18. {
  19. Class.forName(driver);
  20. conexion=(Connection) DriverManager.getConnection(url, usuario, password);
  21.  
  22. if(conexion != null)
  23. System.out.println("Conexion establecida :=)");
  24. }
  25. catch (Exception e)
  26. {
  27. System.err.println("Ocurrio un error: "+e.getMessage());
  28. }
  29. }
  30.  
  31. public static Connection getConexion()
  32. {
  33. return conexion;
  34. }
  35.  
  36. public void desconectar()
  37. {
  38. conexion=null;
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement