Advertisement
Guest User

abas

a guest
Mar 30th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. package m03.uf5.p01.grup5.gestioHospital.utils;
  2.  
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.sql.Connection;
  7. import java.sql.DriverManager;
  8. import java.sql.PreparedStatement;
  9. import java.sql.SQLException;
  10. import java.util.Properties;
  11.  
  12. public class ConexionDB {
  13. public static String url = "jdbc:mysql://localhost:3308/mysql?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC ",
  14. usuario = "root",
  15. pass = "admin";
  16.  
  17. public static Connection contectar(){
  18. Connection conexion = null;
  19. try{
  20. conexion = DriverManager.getConnection(url,usuario,pass);
  21. System.out.println("Conexión establecida");
  22. }catch (Exception e){
  23. System.out.println("Error de conexión a la BD en ConexionDB.java");
  24. System.out.println(e.getMessage());
  25. }
  26. return conexion;
  27. }
  28.  
  29. public PreparedStatement prepareStatement(String select__from_malalties) {
  30. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  31. }
  32. }
  33. ---
  34. /*
  35. * To change this license header, choose License Headers in Project Properties.
  36. * To change this template file, choose Tools | Templates
  37. * and open the template in the editor.
  38. */
  39. package m03.uf5.p01.grup5.gestioHospital.utils;
  40.  
  41. /**
  42. *
  43. * @author Raul Barrero
  44. */
  45. public class Connec {
  46. public static void main(String[] args) {
  47. ConexionDB conexio = new ConexionDB();
  48. conexio.contectar();
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement