SHARE
TWEET

Untitled

a guest Sep 4th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class conne {
  2.  
  3.  
  4.  
  5.  
  6.  
  7.     private Connection con;
  8.  
  9.  
  10.  
  11.     public void connessione() throws Exception{
  12.  
  13.  
  14.  
  15.         if(con != null) return;
  16.  
  17.  
  18.  
  19.         try {
  20.  
  21. //utilizzo il mysql connector 5.47
  22.  
  23.             Class.forName("com.mysql.jdbc.Driver");
  24.  
  25.         } catch (ClassNotFoundException e) {
  26.  
  27.             throw new Exception("No database");
  28.  
  29.         }
  30.  
  31.     //certificazioni sarebbe il nome del database
  32.  
  33.   String connectionURL= "jdbc:mysql://localhost:3306/certificazioni?autoReconnect=true&useSSL=false";
  34.  
  35. //username e password
  36.  
  37.   con = DriverManager.getConnection(connectionURL,"root","rootnino");
  38.  
  39.              
  40.  
  41.     }
  42.  
  43.  
  44.  
  45.     public void close(){
  46.  
  47.         if(con != null){
  48.  
  49.             try {
  50.  
  51.                 con.close();
  52.  
  53.             } catch (SQLException e) {
  54.  
  55.                 e.printStackTrace();
  56.  
  57.             }
  58.  
  59.         }
  60.  
  61.     }
  62.  
  63. }
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