Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dao;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import com.mysql.jdbc.Connection;
- public class Conexao {
- private String driver = "com.mysql.jdbc.Driver";
- private String URL = "jdbc:mysql://localhost/biblioteca";
- private String USER = "root";
- private String SENHA = "root123";
- private Connection conn;
- public Conexao(){
- try{
- Class.forName(driver);
- conn = (Connection) DriverManager.getConnection(URL, USER, SENHA);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
- public Connection getConn(){
- return conn;
- }
- public void closeConn(){
- try {
- conn.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement