-
Notifications
You must be signed in to change notification settings - Fork 0
/
DbConn.java
39 lines (32 loc) · 1.06 KB
/
DbConn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.northcoder.titlelookupservice;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public enum DbConn {
INST;
private Connection conn = null;
DbConn() {
try {
final String jdbcDriver = "com.mysql.cj.jdbc.Driver";
final String dbUrl = "jdbc:mysql://localhost:3306/your_schema_here";
final String user = "your_user_id_here";
final String pass = "your_password_here";
Class.forName(jdbcDriver);
try {
conn = DriverManager.getConnection(dbUrl, user, pass);
} catch (SQLException ex) {
Logger.getLogger(DbConn.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(DbConn.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Connection getDbConn() {
return conn;
}
}