| 6 | import java.sql.Statement; |
| 7 | |
| 8 | public class App { |
| 9 | |
| 10 | private final String url = "jdbc:postgresql://MATERIALIZE_HOST:6875/materialize"; |
| 11 | private final String user = "MATERIALIZE_USERNAME"; |
| 12 | private final String password = "MATERIALIZE_PASSWORD"; |
| 13 | |
| 14 | /** |
| 15 | * Connect to Materialize |
| 16 | * |
| 17 | * @return a Connection object |
| 18 | */ |
| 19 | public Connection connect() throws SQLException { |
| 20 | Properties props = new Properties(); |
| 21 | props.setProperty("user", user); |
| 22 | props.setProperty("password", password); |
| 23 | props.setProperty("ssl","true"); |
| 24 | |
| 25 | return DriverManager.getConnection(url, props); |
| 26 | |
| 27 | } |
| 28 | |
| 29 | public void query() { |
| 30 | |
| 31 | String SQL = "SELECT * FROM my_view"; |
| 32 | |
| 33 | try (Connection conn = connect(); |
| 34 | Statement stmt = conn.createStatement(); |
| 35 | ResultSet rs = stmt.executeQuery(SQL)) { |
| 36 | while (rs.next()) { |
| 37 | System.out.println(rs.getString("my_column")); |
| 38 | } |
| 39 | } catch (SQLException ex) { |
| 40 | System.out.println(ex.getMessage()); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | public static void main(String[] args) { |
| 45 | App app = new App(); |
| 46 | app.query(); |
| 47 | } |
| 48 | } |
nothing calls this directly
no outgoing calls
no test coverage detected