Advertisement
xlrnxnlx

DataAccess | Feeh/iFlash/Beats Leecher

May 18th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package pokedex.dao;
  2. import java.sql.*;
  3.  
  4. public class DataAccess {
  5.    
  6.     private final String
  7.             USERNAME = "", // user do banco
  8.             PASSWORD = "", // password
  9.             JDBC = "oracle.jdbc.OracleDriver",
  10.             DRIVER = "jdbc:oracle:thin:@//localhost:1521/XE";
  11.    
  12.     protected Connection con;
  13.     protected PreparedStatement state;
  14.     protected ResultSet result;
  15.    
  16.     // <editor-fold defaultstate="collapsed" desc="Connect / Disconnect">
  17.     protected boolean connect() {
  18.         boolean success = false;
  19.         try {
  20.             Class.forName(JDBC);
  21.             try {
  22.                 con = DriverManager.getConnection(DRIVER, USERNAME, PASSWORD);
  23.                 success = true;
  24.             } catch (SQLException e) { }
  25.         } catch (ClassNotFoundException e) { }
  26.         return success;
  27.     }
  28.    
  29.     protected boolean disconnect(){
  30.         boolean success = false;
  31.         try {
  32.             con.close();
  33.             success = true;
  34.         } catch (SQLException e) { }
  35.         return success;
  36.     }
  37.     // </editor-fold>
  38.    
  39.     protected java.sql.Date convertToSQL(java.util.Date date) {
  40.         return new java.sql.Date(date.getTime());
  41.     }
  42.    
  43.     protected java.util.Date convertToDate(java.sql.Date date) {
  44.         return new java.util.Date(date.getTime());
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement