-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectDB.java
More file actions
46 lines (43 loc) · 980 Bytes
/
Copy pathConnectDB.java
File metadata and controls
46 lines (43 loc) · 980 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package quest;
import java.sql.*;
import javax.swing.JOptionPane;
public class ConnectDB
{
// String databaseURL = "jdbc:postgresql://localhost:5431/tpch_allidx";
String databaseURL = "jdbc:postgresql://localhost:5432/tpcds";
String databaseUser = "dsladmin";
String databasePassword = "";
public Connection connection;
public ConnectDB(AllObjects allObjects)
{
allObjects.setConnectDBObj(this);
}
public ConnectDB()
{
}
void connectDB()
{
try
{
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(databaseURL, databaseUser, databasePassword);
}
catch(Exception e)
{
System.out.println("Execption in ConnectDB: "+e);
JOptionPane.showMessageDialog(null,"Could not connect to PostgreSQL Server","Error", JOptionPane.ERROR_MESSAGE);
}
}
void disconnectDB()
{
try
{
connection.close();
}
catch(Exception e)
{
System.out.println("Execption in ConnectDB: "+e);
e.printStackTrace();
}
}
}