-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchTrain_DB.java
34 lines (26 loc) · 957 Bytes
/
SearchTrain_DB.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
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class SearchTrain_DB {
private static Connection con = null;
// private static Properties props = new Properties();
//ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
public static Connection getConnection() throws ClassNotFoundException, SQLException {
try{
// FileInputStream fis = null;
// fis = new FileInputStream("database.properties");
// props.load(fis);
// load the Driver Class
Class.forName("com.mysql.cj.jdbc.Driver");
// create the connection now
con = DriverManager.getConnection("jdbc:mysql:///trains","root","rps@12345");
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
}