Advertisement
Guest User

Untitled

a guest
May 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. package database;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.util.Properties;
  7.  
  8. import config.SProperties;
  9.  
  10. public class UserDatabase {
  11. private static final Properties properties = SProperties.getProperties();
  12.  
  13. private static final String host = properties.getProperty("DBHost");
  14. private static final String port = properties.getProperty("DBPort");
  15. private static final String database = properties.getProperty("DBDatabase");
  16. private static final String username = properties.getProperty("DBUsername");
  17. private static final String password = properties.getProperty("DBPassword");
  18.  
  19. public synchronized final static Connection getInstance() throws ClassNotFoundException, SQLException {
  20. Class.forName("com.mysql.jdbc.Driver");
  21. return DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement