-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetConnection.java
More file actions
24 lines (22 loc) · 865 Bytes
/
GetConnection.java
File metadata and controls
24 lines (22 loc) · 865 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
package BigWork1;
import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
public class GetConnection {
private Connection connection = null;
private Properties pros = null;
public Connection connect() throws Exception{
pros = new Properties();
BufferedReader bufferedReader = new BufferedReader(new FileReader("J2SE/src/BigWork1/conn.properties"));
pros.load(bufferedReader);
String driver = pros.getProperty("driver");
String url = pros.getProperty("url");
String user = pros.getProperty("user");
String password = pros.getProperty("password");
Class.forName(driver);
connection = DriverManager.getConnection(url,user,password);
return connection;
}
}