public static Connection getConnection() {
            try {
                if (connection == null || connection.isClosed()) {

                        Class.forName("com.mysql.jdbc.Driver");
                        String url = "jdbc:mysql://localhost:3306/pi";
                        String user = "root";
                        String password = "admin";

                        connection = DriverManager.getConnection(url, user,password);
                        connection.setAutoCommit(false);

                        Logger.getLogger(ConnectionManager.class.getName()).log(Level.INFO, "Conexão estabelecida.");
                } 
            } catch (ClassNotFoundException e) {
                Logger.getLogger(ConnectionManager.class.getName()).log(Level.SEVERE, "Driver não encontrado.", e);
            } catch (SQLException ex) {
                Logger.getLogger(ConnectionManager.class.getName()).log(Level.SEVERE, "Conexão NÃO estabelecida.", ex);
            } 
            return connection;
	}