SHARE
TWEET

Untitled

a guest Oct 21st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5.  
  6. public class BDConnection {
  7.  
  8.     private static Connection conexion = null;
  9.    
  10.    
  11.    
  12.     private BDConnection() {
  13.        
  14.         private String user ="root";
  15.         private String pass = "P@ssword";
  16.             private String servidor = "localhost";
  17.             private String puerto = "3306";
  18.             private String baseDatos = "cines";
  19.    
  20.        
  21.         try {
  22.             Class.forName("com.mysql.jdbc.Driver");
  23.             String dbURL = "jdbc:mysql://"+servidor+":"+puerto+"/"+baseDatos
  24.                     + "?verifyServerCertificate=true"
  25.                     + "&useSSL=false"
  26.                     + "&requireSSL=false";
  27.                     conexion = DriverManager.getConnection(dbURL, user, pass);
  28.         }
  29.         catch (Exception ex) {
  30.             ex.printStackTrace();
  31.         }          
  32.     }
  33.    
  34.    
  35.    
  36.    
  37.     public static Connection getConexion() {
  38.    
  39.         if(conexion==null) {
  40.            
  41.             new BDConnection();
  42.         }
  43.        
  44.         return conexion;
  45.     }
  46.    
  47.    
  48.    
  49.    
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top