-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChessResultsDBUtil.java
More file actions
42 lines (33 loc) · 884 Bytes
/
Copy pathChessResultsDBUtil.java
File metadata and controls
42 lines (33 loc) · 884 Bytes
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
40
41
42
package edu.unlv.mis768.finalproject;
/**
* This class establishes connection to the ChessResultsDB
*/
import java.sql.*;
public class ChessResultsDBUtil {
/**
* This method establishes the DB connection
* @return a database connection
*/
public static Connection getDBConnection(){
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ChessResultsDB", "root", "ENTER PASSWORD");
} catch (Exception ex) {
System.out.println("ERROR: " + ex.getMessage());
}
return conn;
}
/**
* This method closes the DB connection
* @param the connection to be closed
*/
public static void closeDBConnection(Connection conn) {
if (conn != null) {
try {
conn.close();
} catch (Exception ex) {
System.out.println("ERROR: " + ex.getMessage());
}
}
}
}