forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibUtil.java
More file actions
40 lines (33 loc) · 1.08 KB
/
LibUtil.java
File metadata and controls
40 lines (33 loc) · 1.08 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
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
/*
* 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 testuser
*/
public class LibUtil {
public static Connection getConnection() {
Connection conn = null;
try {
Properties prop = new Properties();
FileInputStream in = new FileInputStream("src/DBProperties");
prop.load(in);
String driverName= prop.getProperty("DBDriver");
Class.forName(driverName);
String dbName,user,password;
dbName= prop.getProperty("DBName");
user = prop.getProperty("User");
password= prop.getProperty("Password");
conn= DriverManager.getConnection(dbName, user, password);
return conn;
} catch (Exception e) {
}
return conn;
}
}