Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Renzo Alamo
Added: Nov 6, 2018 6:34 PM
Views: 4
Tags: no tags
  1.     private Connection conn;
  2.     private String className, url, user, password;
  3.  
  4.     public void setConn(String className, String url, String user, String password) {
  5.         this.className = className;
  6.         this.url = url;
  7.         this.user = user;
  8.         this.password = password;
  9.         try {
  10.             if (Class.forName(className) != null) {
  11.                 try {
  12.                     this.conn = DriverManager.getConnection(url, user, password);
  13.                 } catch (SQLException e) {
  14.                 }
  15.             }
  16.         } catch (ClassNotFoundException e) {
  17.         }
  18.     }
  19.  
  20.     public String getClassName() {
  21.         return className;
  22.     }
  23.  
  24.     public String getUrl() {
  25.         return url;
  26.     }
  27.  
  28.     public String getUser() {
  29.         return user;
  30.     }
  31.  
  32.     public String getPassword() {
  33.         return password;
  34.     }
  35.  
  36.     public Connection getConn() {
  37.         return conn;
  38.     }