Guest User

Untitled

a guest
Mar 7th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. jdbc.driverClassName = com.mysql.jdbc.Driver
  2. jdbc.url = jdbc:mysql://localhost:3306/testdb
  3. jdbc.username = root
  4. jdbc.password =
  5.  
  6. //Default Constructor
  7. public DBManagerImpl(){
  8. JDBC_DRIVER = getResource().getProperty("jdbc.driverClassName","com.mysql.jdbc.Driver");
  9. try {
  10. Class.forName(JDBC_DRIVER);
  11. }...
  12. }
  13.  
  14. //Getting properties file
  15. private Properties getResource(){
  16. Properties prop = new Properties();
  17. InputStream input = null;
  18. try {
  19. input = getClass().getClassLoader().getResourceAsStream("config.properties");
  20. prop.load(input);
  21. } ...
  22. return prop;
  23. }
  24.  
  25. public Connection getConnection() {
  26. Connection connection = null;
  27. try {
  28. DATABASE_URL = getResource().getProperty("jdbc.url", "jdbc:mysql://localhost:3306/defaultdb");
  29. username = getResource().getProperty("jdbc.username", "root");
  30. password = getResource().getProperty("jdbc.password", "");
  31. connection = DriverManager.getConnection(DATABASE_URL, username, password);
  32. } ...
  33. return connection;
  34. }
Add Comment
Please, Sign In to add comment