List of utility methods to do JDBC Derby Connection
int | getSize2() get Size Connection conn = DriverManager.getConnection(protocol + dbName + ";create=true"); String sql = "select count(*) from whore2"; PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); rs.next(); int id = rs.getInt(1); rs.close(); ps.close(); ... |
ArrayList | getTables(File database) get Tables String DB_CONNECTION_STRING = "jdbc:derby:" + database; Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Connection conn = (Connection) DriverManager.getConnection(DB_CONNECTION_STRING); DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getTables(null, null, null, null); ArrayList<String> tables = new ArrayList<String>(); while (rs.next()) { if (rs.getString("TABLE_SCHEM").equals("APP")) ... |
ResultSet | printStats(String statstring) Executes an arbitrary SQL query and returns the result. boolean successful = true; try { System.out.println("Connected to database " + dbName); s = conn.createStatement(); statements.add(s); System.out.println("---Reading Statistics---"); rs = s.executeQuery(statstring); } catch (SQLException sqle) { ... |
void | removeUnitDB() remove Unit DB try { DriverManager.getConnection("jdbc:derby:memory:flexims;drop=true", "flexims", "123456"); } catch (SQLException e) { |
int | saveContact(String fName, String lName) save Contact int pk = (fName + lName).hashCode(); loadDriver(); Connection conn = null; ArrayList statements = new ArrayList(); PreparedStatement psInsert = null; Statement s = null; ResultSet rs = null; try { ... |
void | startDerby() start Derby Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Properties props = new Properties(); Connection conn = DriverManager.getConnection("jdbc:derby:memory:derbyDB;create=true", props); Statement statement = conn.createStatement(); statement.execute("CREATE SCHEMA KMSADMIN"); statement.execute("SET SCHEMA KMSADMIN"); statement.execute("CREATE SEQUENCE RANGER_MASTERKEY_SEQ START WITH 1 INCREMENT BY 1"); String tableCreationString = "CREATE TABLE ranger_masterkey (id VARCHAR(20) NOT NULL PRIMARY KEY, create_time DATE," ... |
void | startDerbyInEmbeddedMode() Starts derby server in embedded mode. Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close(); |
void | stopDerby() stop Derby try { DriverManager.getConnection("jdbc:derby:memory:derbyDB;drop=true"); } catch (SQLException ex) { |