-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBConnection.java
More file actions
41 lines (34 loc) · 1.06 KB
/
DBConnection.java
File metadata and controls
41 lines (34 loc) · 1.06 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author acv
*/
public class DBConnection {
private static Connection connection;
private static final String user = "java";
private static final String password = "java";
private static final String database = "jdbc:derby://localhost:1527/CourseSchedulerDBNathanielSmithnss5405";
public static Connection getConnection()
{
if (connection == null)
{
try
{
connection = DriverManager.getConnection(database, user, password);
} catch (SQLException e)
{
e.printStackTrace();
System.out.println("Could not open database.");
System.exit(1);
}
}
return connection;
}
}