public void dumpCases() { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = con.createStatement("SELECT * FROM " + prefix + "_case_"); DbResult res = sta.executeQuery(prop); while(res.next()) { System.out.println("CASE:"); for (String name : res.getColumnNames()) if (!name.toLowerCase().equals("content_")) System.out.println(" " + name + ": " + res.getString(name)); } } catch (Exception e) { throw new RuntimeException(e); } }
public void dumpNodes() { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = con.createStatement("SELECT * FROM " + prefix + "_node_"); DbResult res = sta.executeQuery(prop); while(res.next()) { System.out.println("NODE:"); for (String name : res.getColumnNames()) if (!name.toLowerCase().equals("content_")) System.out.println(" " + name + ": " + res.getString(name)); } } catch (Exception e) { throw new RuntimeException(e); } }
/** * <p>existsObject.</p> * * @param con a {@link de.mhus.lib.sql.DbConnection} object. * @param keys an array of {@link java.lang.Object} objects. * @return a boolean. * @throws java.lang.Exception if any. */ public boolean existsObject(DbConnection con, Object[] keys) throws Exception { HashMap<String, Object> attributes = new HashMap<String, Object>(); int nr = 0; for (Object key : keys) { attributes.put(String.valueOf(nr), key); nr++; } DbResult ret = sqlPrimary.getStatement(con).executeQuery(attributes); if (!ret.next()) { ret.close(); return false; } ret.close(); return true; }
@Override public Result<PCaseInfo> getCases(STATE_CASE state) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_"); } else { prop.put("state", state); sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_ WHERE state_=$state$"); } DbResult res = sta.executeQuery(prop); return new SqlResultCase(con,res); } catch (Exception e) { throw new IOException(e); } }
nr++; DbResult ret = sqlPrimary.getStatement(con).executeQuery(attributes); if (!ret.next()) { ret.close();
@Override public Result<PNodeInfo> getFlowNodes(UUID caseId, STATE_NODE state) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (caseId == null && state == null) { sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_"); } else if (caseId == null) { prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$"); } else if (state == null) { prop.setString("case", caseId.toString()); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE case_=$case$"); } else { prop.setString("case", caseId.toString()); prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$ and case_=$case$"); } DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) { throw new IOException(e); } }
DbResult res = sta.executeQuery(prop); exists = res.next(); res.close();
nr++; DbResult ret = sqlPrimary.getStatement(con).executeQuery(attributes); if (!ret.next()) { ret.close();
@Override public PEngine loadEngine() throws IOException, NotFoundException { PEngine engine = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", "engine"); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_engine_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); engine = new PEngine(); engine.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (engine == null) throw new NotFoundException("engine"); return engine; }
@Override public PCase loadCase(UUID id) throws IOException, NotFoundException { PCase caze = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_case_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); caze = new PCase(); caze.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (caze == null) throw new NotFoundException("case",id); return caze; }
@Override public Result<PNodeInfo> getScheduledFlowNodes(STATE_NODE state, long scheduled) throws IOException { DbConnection con = null; try { con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { prop.setLong("scheduled", scheduled); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE scheduled_ <= $scheduled$"); } else { prop.setLong("scheduled", scheduled); prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$ and scheduled_ <= $scheduled$"); } DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) { try { if (con != null) con.close(); } catch (Exception e2) {} throw new IOException(e); } }
@Override public Result<PNodeInfo> getSignalFlowNodes(STATE_NODE state, String signal) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { prop.setString("signal", "%" + PNode.getSignalAsString(signal) + "%"); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE signal_ like $signal$"); } else { prop.setString("signal", "%" + PNode.getSignalAsString(signal) + "%"); prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$ and signal_ like $signal$"); } DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) { throw new IOException(e); } }
@Override public PCaseInfo loadCaseInfo(UUID caseId) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", caseId); sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (!res.next()) { res.close(); con.close(); return null; } PCaseInfo out = newPCase(res); res.close(); con.close(); return out; } catch (Exception e) { throw new IOException(e); } }
@Override public PNodeInfo loadFlowNodeInfo(UUID nodeId) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", nodeId); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (!res.next()) { res.close(); con.close(); return null; } PNodeInfo out = newPNode(res); res.close(); con.close(); return out; } catch (Exception e) { throw new IOException(e); } }
@Override public PNode loadFlowNode(UUID id) throws IOException, NotFoundException { PNode node = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_node_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); node = new PNode(); try { node.readExternal(new ObjectInputStream(in)); } catch (java.io.EOFException eofe) { log().w(node,eofe); // most because of extended parameters } } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (node == null) throw new NotFoundException("node",id); return node; }
nr++; DbResult ret = sqlPrimary.getStatement(con).executeQuery(attributes); if (!ret.next()) { ret.close();
try { DbStatement sth = con.createStatement(query); DbResult res = sth.executeQuery(map); return new DbCollectionImpl<T>(this,con,myCon != null,registryName,clazz,res); } catch (Throwable t) {
try { DbStatement sth = con.createStatement(query); DbResult res = sth.executeQuery(map); LinkedList<T> out = new LinkedList<>(); while (res.next()) {
DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) {
try { sth = con.createStatement(query); res = sth.executeQuery(map); long count = -1; while(res.next())