Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public class DBSingleton {
  2. private static final DBSingleton ONLY_ONE = new DBSingleton();
  3. private Connection connection = null;
  4. private DBSingleton() {
  5. try {
  6. Class.forName("com.mysql.jdbc.Driver");
  7. connection = DriverManager.getConnection("jdbc:mysql://rds-mysql-sanria.czqrdgrwq7kk.ap-south-1.rds.amazonaws.com:3306/BIM", "sanriadb","12345678");// SQLException
  8. } catch (ClassNotFoundException | SQLException e) {
  9. e.printStackTrace();
  10. }
  11. }
  12.  
  13. public static DBSingleton getInstance() {
  14. return ONLY_ONE;
  15. }
  16.  
  17. public Connection getcon() {
  18. return connection;
  19. }
  20. }
  21.  
  22. private Connection con = DBSingleton.getInstance().getcon();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement