-
Notifications
You must be signed in to change notification settings - Fork 9
/
connection.java
37 lines (32 loc) · 1.02 KB
/
connection.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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class App {
private final String url = "jdbc:postgresql://MATERIALIZE_HOST:6875/materialize";
private final String user = "MATERIALIZE_USERNAME";
private final String password = "MATERIALIZE_PASSWORD";
/**
* Connect to Materialize
*
* @return a Connection object
*/
public Connection connect() {
Properties props = new Properties();
props.setProperty("user", user);
props.setProperty("password", password);
props.setProperty("ssl","true");
Connection conn = null;
try {
conn = DriverManager.getConnection(url, props);
System.out.println("Connected to Materialize successfully!");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return conn;
}
public static void main(String[] args) {
App app = new App();
app.connect();
}
}