Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package juninho.persistencia;
  6.  
  7. import java.sql.Connection;
  8. import java.sql.DriverManager;
  9. import java.sql.PreparedStatement;
  10.  
  11. /**
  12.  *
  13.  * @author Juninho
  14.  */
  15. public class Dao {
  16.     Connection con;
  17.     PreparedStatement pstmt;
  18.    
  19.     public void abrirBanco() throws Exception {
  20.         Class.forName("com.mysql.jdbc.driver");
  21.         String url = "jdbc:mysql://localhost:3306/vab";
  22.         String usuario = "root";
  23.         String senha = "";
  24.         con = DriverManager.getConnection(url, usuario, senha);
  25.     }
  26.    
  27.     public void fecharBanco() throws Exception {
  28.         if(con != null){
  29.             con.close();
  30.         }
  31.         if(pstmt != null){
  32.             pstmt.close();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement