@Override public synchronized void close() { if (res == null) return; try { res.close(); } catch (Exception e) {} con.close(); res = null; con = null; }
@Override public synchronized void close() { if (res == null) return; try { res.close(); } catch (Exception e) {} con.close(); res = null; con = null; }
/** * <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 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 void close() { if (res != null) { try { res.close(); } catch (Exception e) { log().w(e); } res = null; next = null; hasNext = false; object = null; } if (con != null) { if (ownConnection) manager.getSchema().closeConnection(pool,con); con = null; } }
@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); } }
ret.close(); return null;
DbResult res = sta.executeQuery(prop); 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; }
@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 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; }
res.close(); sth.close(); } catch (Throwable t) {
} finally { try { if (res != null) res.close(); if (sth != null) sth.close(); if (myCon != null) schema.closeConnection(pool, myCon);
DbResult res = sta.executeQuery(prop); exists = res.next(); res.close(); sta.close();
DbResult res = sta.executeQuery(prop); exists = res.next(); res.close(); sta.close();