public SqlResultNode(DbConnection con, DbResult res) throws Exception { this.con = con; this.res = res; hasNext = res.next(); }
public SqlResultCase(DbConnection con, DbResult res) throws Exception { this.con = con; this.res = res; hasNext = res.next(); }
@Override public PNodeInfo next() { if (res == null) return null; try { PNodeInfo out = newPNode(res); hasNext = res.next(); return out; } catch (Exception e) { throw new MRuntimeException(e); } } }
@Override public PCaseInfo next() { if (res == null) return null; try { PCaseInfo out = newPCase(res); hasNext = res.next(); return out; } catch (Exception e) { throw new MRuntimeException(e); } } }
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; }
if (!ret.next()) { ret.close(); return null;
exists = res.next(); res.close(); sta.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; }
if (!ret.next()) { ret.close(); return null;
@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 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; }
try { hasNext = res.next(); if (hasNext) { O out = object;
if (!ret.next()) { ret.close(); log().d("row not found");
DbResult res = sth.executeQuery(map); LinkedList<T> out = new LinkedList<>(); while (res.next()) { out.add( (T)res.getObject(alias));
res = sth.executeQuery(map); long count = -1; while(res.next()) count=res.getLong(attributeName); return count;
exists = res.next(); res.close(); sta.close();