forked from Akanksha810/Bug-Tracking-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBUtil.java
41 lines (33 loc) · 967 Bytes
/
DBUtil.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
35
36
37
38
39
40
41
package com.code.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBUtil {
static Connection conn=null;
public static Connection getMyConnection() {
if(conn==null) {
try {
//DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
String url = "jdbc:derby:C:\\bugtrackproject\\bugtrackdb";
String user = "hsbc";
String password = "hsbc123";
conn = DriverManager.getConnection(url, user, password);
if (conn != null) {
System.out.println("Connected to database ");
}
} catch (SQLException e) {
System.out.println("Connection not done derby ");
e.printStackTrace();
}
}
return conn;
}
public static void closeMyConnection() {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}