MCPcopy Create free account
hub / github.com/MaterializeInc/demos / App

Class App

connection-examples/java/source.java:9–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7import java.sql.PreparedStatement;
8
9public class App {
10
11 private final String url = "jdbc:postgresql://MATERIALIZE_HOST:6875/materialize";
12 private final String user = "MATERIALIZE_USERNAME";
13 private final String password = "MATERIALIZE_PASSWORD";
14
15 /**
16 * Connect to Materialize
17 *
18 * @return a Connection object
19 */
20 public Connection connect() throws SQLException {
21 Properties props = new Properties();
22 props.setProperty("user", user);
23 props.setProperty("password", password);
24 props.setProperty("ssl","true");
25
26 return DriverManager.getConnection(url, props);
27
28 }
29
30 public void source() {
31
32 String SQL = "CREATE SOURCE counter FROM "
33 + "LOAD GENERATOR COUNTER";
34
35 try (Connection conn = connect()) {
36 Statement st = conn.createStatement();
37 st.execute(SQL);
38 System.out.println("Source created.");
39 st.close();
40 } catch (SQLException ex) {
41 System.out.println(ex.getMessage());
42 }
43 }
44
45 public static void main(String[] args) {
46 App app = new App();
47 app.source();
48 }
49}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected