Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public class JDBCUtil {
  2.     private static Connection CONNECTION;
  3.  
  4.     static {
  5.         try {
  6.             Class.forName("org.postgresql.Driver");
  7.         } catch (ClassNotFoundException ex){
  8.             ex.printStackTrace();
  9.         }
  10.     }
  11.  
  12.     public static Connection getConnection() {
  13.         CONNECTION = null;
  14.         try {
  15.             CONNECTION = DriverManager.getConnection("jdbc:postgresql://localhost:5432/musicLibrary", "postgres", "qwe123");
  16.         } catch (SQLException ex){
  17.             System.out.println(ex.getMessage());
  18.         }
  19.         return CONNECTION;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement