Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pokedex.dao;
- import java.sql.*;
- public class DataAccess {
- private final String
- USERNAME = "", // user do banco
- PASSWORD = "", // password
- JDBC = "oracle.jdbc.OracleDriver",
- DRIVER = "jdbc:oracle:thin:@//localhost:1521/XE";
- protected Connection con;
- protected PreparedStatement state;
- protected ResultSet result;
- // <editor-fold defaultstate="collapsed" desc="Connect / Disconnect">
- protected boolean connect() {
- boolean success = false;
- try {
- Class.forName(JDBC);
- try {
- con = DriverManager.getConnection(DRIVER, USERNAME, PASSWORD);
- success = true;
- } catch (SQLException e) { }
- } catch (ClassNotFoundException e) { }
- return success;
- }
- protected boolean disconnect(){
- boolean success = false;
- try {
- con.close();
- success = true;
- } catch (SQLException e) { }
- return success;
- }
- // </editor-fold>
- protected java.sql.Date convertToSQL(java.util.Date date) {
- return new java.sql.Date(date.getTime());
- }
- protected java.util.Date convertToDate(java.sql.Date date) {
- return new java.util.Date(date.getTime());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement