Package java.sql

Examples of java.sql.PreparedStatement.clearBatch()


                insertRuleRelation.setLong(1,program.getId());
                insertRuleRelation.setLong(2,rule.getId());
                insertRuleRelation.addBatch();
            }
            insertRuleRelation.executeBatch();
            insertRuleRelation.clearBatch();
        }

        // done
    }
View Full Code Here


            }

            //    2b) check if namespaces have been removed, and remove them if necessary from the database
            PreparedStatement deleteProgramNS = getPreparedStatement("programs.delete_ns");
            synchronized (deleteProgramNS) {
                deleteProgramNS.clearBatch();
                for(Map.Entry<String,String> oldNS : old.getNamespaces().entrySet()) {
                    if(!program.getNamespaces().entrySet().contains(oldNS)) {
                        deleteProgramNS.setLong(1,old.getId());
                        deleteProgramNS.setString(2,oldNS.getKey());
                        deleteProgramNS.setString(3,oldNS.getValue());
View Full Code Here

            }

            //    2c) check if namespaces have been added, and add them if necessary to the database
            PreparedStatement addProgramNS = getPreparedStatement("programs.add_ns");
            synchronized (addProgramNS) {
                addProgramNS.clearBatch();
                for(Map.Entry<String,String> newNS : program.getNamespaces().entrySet()) {
                    if(!old.getNamespaces().entrySet().contains(newNS)) {
                        addProgramNS.setLong(1,old.getId());
                        addProgramNS.setString(2, newNS.getKey());
                        addProgramNS.setString(3, newNS.getValue());
View Full Code Here

            //    2d) check if rules have been removed, and remove them if necessary from the database
            PreparedStatement deleteProgramRule = getPreparedStatement("programs.delete_rule");
            PreparedStatement deleteRule        = getPreparedStatement("rules.delete_by_id");
            synchronized (deleteProgramRule) {
                deleteProgramRule.clearBatch();
                deleteRule.clearBatch();
                for(Rule oldRule : old.getRules()) {
                    if(!program.getRules().contains(oldRule)) {
                        deleteProgramRule.setLong(1,old.getId());
                        deleteProgramRule.setLong(2,oldRule.getId());
                        deleteProgramRule.addBatch();
View Full Code Here

            // first create a new entry in the rules table
            PreparedStatement insertRule = getPreparedStatement("rules.insert");
            PreparedStatement addProgramRule = getPreparedStatement("programs.add_rule");
            synchronized (insertRule) {
                insertRule.clearBatch();
                addProgramRule.clearBatch();

                for(Rule rule : program.getRules()) {
                    if(!old.getRules().contains(rule)) {
                        rule.setId(getNextSequence("seq.rules"));
View Full Code Here

        // 1. delete all rule associations and rules including the justifications they depend on
        PreparedStatement deleteProgramRule = getPreparedStatement("programs.delete_rule");
        PreparedStatement deleteRule        = getPreparedStatement("rules.delete_by_id");
        synchronized (deleteProgramRule) {
            deleteProgramRule.clearBatch();
            deleteRule.clearBatch();
            for(Rule rule : program.getRules()) {
                deleteProgramRule.setLong(1, program.getId());
                deleteProgramRule.setLong(2, rule.getId());
                deleteProgramRule.addBatch();
View Full Code Here

        }

        // 2. delete all namespaces
        PreparedStatement deleteProgramNS = getPreparedStatement("programs.delete_ns");
        synchronized (deleteProgramNS) {
            deleteProgramNS.clearBatch();
            for(Map.Entry<String,String> ns : program.getNamespaces().entrySet()) {
                deleteProgramNS.setLong(1,   program.getId());
                deleteProgramNS.setString(2, ns.getKey());
                deleteProgramNS.setString(3, ns.getValue());
                deleteProgramNS.addBatch();
View Full Code Here

        PreparedStatement justificationAddRule   = getPreparedStatement("justifications.add_rule");

        synchronized (insertJustification) {
            insertJustification.clearBatch();
            justificationAddTriple.clearBatch();
            justificationAddRule.clearBatch();

            for(Justification j : justifications) {
                if(j.getId() >= 0) {
                    log.warn("justification is already stored in database, not persisting again (database ID: {})", j.getId());
                } else {
View Full Code Here

        PreparedStatement deleteJustificationTriples = getPreparedStatement("justifications.del_triple");

        synchronized (deleteJustification) {
            deleteJustification.clearBatch();
            deleteJustificationRules.clearBatch();
            deleteJustificationTriples.clearBatch();

            while(justifications.hasNext()) {
                Justification j = justifications.next();
                if(j.getId() < 0) {
                    log.error("cannot delete justification since it does not have a database ID");
View Full Code Here

        pStmt.addBatch();
        pStmt.setInt(1, 2);
        pStmt.addBatch();
        pStmt.setInt(1, 3);
        pStmt.addBatch();
        pStmt.clearBatch();
        /* there were 0 statements in the batch,
         * update count length should be 0 */
        assertBatchUpdateCounts(new int[] {}, pStmt.executeBatch());

        println("Positive Prepared Stat: " +
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.