-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBConnection.java
More file actions
36 lines (31 loc) · 1 KB
/
DBConnection.java
File metadata and controls
36 lines (31 loc) · 1 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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/*
* 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.
*/
/**
*
* @author Punya
*/
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/RoomSchedulerDBPunyapzs5530";
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 the database.");
System.exit(1);
}
}
return connection;
}
}