@Override public void deleteCaseAndFlowNodes(UUID id) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); { DbStatement sta = con.createStatement("DELETE FROM " + prefix + "_case_ WHERE id_=$id$"); sta.execute(prop); } { DbStatement sta = con.createStatement("DELETE FROM " + prefix + "_node_ WHERE case_=$id$"); sta.execute(prop); } con.commit(); con.close(); } catch (Exception e) { throw new IOException(e); } }
@Override public Parser createQueryCompiler(String language) throws MException { return instance.createQueryCompiler(language); }
@Override public String getDefaultLanguage() { return instance.getDefaultLanguage(); }
@Override public boolean setNodeScope(UUID nodeId, int scope) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", nodeId); prop.put("value", scope); sta = con.createStatement("UPDATE " + prefix + "_node_ SET scope_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
/** * Return a statement for the given connection - hopefully from the same pool. * * @param con * @return x * @throws Exception */ public DbStatement getStatement(DbConnection con) throws Exception { return con.createStatement(this); }
/** * Close the default connection given with getConnection(). * @param pool * * @param con */ public void closeConnection(DbPool pool, DbConnection con) { DbConnection c = (DbConnection) DbTransaction.getConnection(pool); if (c != null) return; con.close(); }
@Override public void commit() throws Exception { instance.commit(); }
public ConnectionTrace(DbConnection con) { id = con.getInstanceId(); time = System.currentTimeMillis(); stackTrace = Thread.currentThread().getStackTrace(); }
Connection con = ((JdbcConnection)db.instance()).getConnection(); Statement sth = con.createStatement();
@Override public boolean isClosed() { if (instance == null) return true; return instance.isClosed(); }
@Override public DbStatement getStatement(String name) throws MException { return instance.getStatement(name); }
@Override public String[] getLanguages() { return instance.getLanguages(); }
@Override public boolean setCasePriority(UUID caseId, int priority) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", caseId); prop.put("value", priority); sta = con.createStatement("UPDATE " + prefix + "_case_ SET priority_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
@Override public DbStatement createStatement(DbPrepared dbPrepared) { return instance.createStatement(dbPrepared); }
@Override public synchronized void close() { if (res == null) return; try { res.close(); } catch (Exception e) {} con.close(); res = null; con = null; }
/** * Used to commit a default connection. See getConnection() * @param pool * @param con * @throws Exception */ public void commitConnection(DbPool pool, DbConnection con) throws Exception { DbConnection c = (DbConnection) DbTransaction.getConnection(pool); if (c != null) return; con.commit(); }
public DbConnectionProxy(DbPool pool, DbConnection instance) { if (traceCaller.value()) { this.pool = pool; pool.getStackTraces().put(MSystem.getObjectId(this), new ConnectionTrace(this)); // instance.setUsedTrace(createStackTrace); } this.instance = instance; log().t(id,"created",instance.getInstanceId()); }
public void createIndexes(IConfig data, DbConnection db, MetadataBundle caoMeta, boolean cleanup) throws Exception { Connection con = ((JdbcConnection)db.instance()).getConnection(); Statement sth = con.createStatement(); DatabaseMetaData meta = con.getMetaData();
prop.put("id", "engine"); DbStatement sta = con.createStatement("SELECT id_ FROM " + prefix + "_engine_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); exists = res.next(); prop.put("modified", new Date()); if (exists) { DbStatement sta = con.createStatement("UPDATE " + prefix + "_engine_ SET content_=$content$,modified_=$modified$ WHERE id_=$id$"); sta.executeUpdate(prop); sta.close(); DbStatement sta = con.createStatement("INSERT INTO " + prefix + "_engine_ (id_,content_,created_,modified_) VALUES ($id$,$content$,$created$,$modified$)"); sta.executeUpdate(prop); sta.close(); con.commit(); con.close(); } catch (Exception e) { throw new IOException(e);