| 7 | import java.sql.PreparedStatement; |
| 8 | |
| 9 | public 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 view() { |
| 31 | String SQL = "CREATE VIEW market_orders_2 AS " |
| 32 | + "SELECT " |
| 33 | + " val->>'symbol' AS symbol, " |
| 34 | + " (val->'bid_price')::float AS bid_price " |
| 35 | + "FROM (SELECT text::jsonb AS val FROM market_orders_raw_2)"; |
| 36 | |
| 37 | try (Connection conn = connect()) { |
| 38 | Statement st = conn.createStatement(); |
| 39 | st.execute(SQL); |
| 40 | System.out.println("View created."); |
| 41 | st.close(); |
| 42 | } catch (SQLException ex) { |
| 43 | System.out.println(ex.getMessage()); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | public static void main(String[] args) { |
| 48 | App app = new App(); |
| 49 | app.view(); |
| 50 | } |
| 51 | } |
nothing calls this directly
no outgoing calls
no test coverage detected