Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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.  
  10. public Connection getConnection() throws DAOException {
  11. try {
  12. return DriverManager.getConnection(url, username, password);
  13.  
  14. } catch (SQLException e) {
  15.  
  16. String SQLmessage = e.getMessage();
  17. String SQLstate = e.getSQLState();
  18. int vendorcode = e.getErrorCode();
  19.  
  20. resultLog.error("An excetion hasse occured");
  21. resultLog.error("Message : " + SQLmessage);
  22. resultLog.error("Sate : " + SQLstate);
  23. resultLog.error("VendorCode : " + vendorcode);
  24.  
  25.  
  26. } catch (Exception e) {
  27. throw new DAOException();
  28. }
  29.  
  30. return null;
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement