Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class BaseDAO implements DAO {
  2.  
  3. final Logger resultLog = Logger.getLogger(BaseDAO.class);
  4.  
  5. static final String driver = DBTools.propertieReader("driver");
  6. String url = DBTools.propertieReader("url");
  7. String username = DBTools.propertieReader("username");
  8. String password = DBTools.propertieReader("password");
  9. Connection con = null;
  10. public Connection getConnection() throws DAOException {
  11.  
  12. try {
  13. con = DriverManager.getConnection(url, username, password);
  14.  
  15. } catch (SQLException e) {
  16.  
  17. String SQLmessage = e.getMessage();
  18. String SQLstate = e.getSQLState();
  19. int vendorcode = e.getErrorCode();
  20.  
  21. resultLog.error("An excetion hasse occured");
  22. resultLog.error("Message : " + SQLmessage);
  23. resultLog.error("Sate : " + SQLstate);
  24. resultLog.error("VendorCode : " + vendorcode);
  25.  
  26.  
  27. } catch (Exception e) {
  28. throw new DAOException();
  29. }
  30.  
  31. return con;
  32.  
  33. }
  34.  
  35. public void CloseConnection(){
  36. try {
  37. con.close();
  38. } catch (SQLException e) {
  39. resultLog.error(e.getMessage());
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement