Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package dao;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author sidney
- */
- public class Database {
- private String user = "root";
- private String password = "1234";
- private String db = "petshop";
- protected Connection connection;
- public int connect() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- this.connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+db,this.user,this.password);
- return 1;
- } catch(SQLException ex) {
- return 0;
- } catch(ClassNotFoundException x) {
- return 0;
- }
- }
- public void desconectar() {
- try {
- this.connection.close();
- } catch (SQLException ex) {
- }
- }
- }
Add Comment
Please, Sign In to add comment