Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class conne {
- private Connection con;
- public void connessione() throws Exception{
- if(con != null) return;
- try {
- //utilizzo il mysql connector 5.47
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- throw new Exception("No database");
- }
- //certificazioni sarebbe il nome del database
- String connectionURL= "jdbc:mysql://localhost:3306/certificazioni?autoReconnect=true&useSSL=false";
- //username e password
- con = DriverManager.getConnection(connectionURL,"root","rootnino");
- }
- public void close(){
- if(con != null){
- try {
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement