Package net.sourceforge.jivalo.cnfmgr.persistent

Examples of net.sourceforge.jivalo.cnfmgr.persistent.PreparedStatementParameter


        String lineSeparator = System.getProperty("line.separator");
        sb.append(lineSeparator);
        List parameters = new ArrayList(attributes.size() + conditions.size());
        for (Iterator i = attributes.iterator(); i.hasNext(); ) {
            SqlAttribute attribute = (SqlAttribute) i.next();
            parameters.add(new PreparedStatementParameter(attribute.value,
                attribute.type));
            sb.append("\tBinding: ");
            sb.append(attribute.columnName);
            sb.append(" -> ");
            sb.append(attribute.value);
            sb.append(lineSeparator);
        }

        for (Iterator i = conditions.iterator(); i.hasNext(); ) {
            SqlCondition condition = (SqlCondition) i.next();
            parameters.add(new PreparedStatementParameter(condition.value,
                condition.type));
            sb.append("\tBinding: ");
            sb.append(condition.columnName);
            sb.append(" -> ");
            sb.append(condition.value);
View Full Code Here


        String[] names = split(nodeName);
        try {
            PersistentConnectorClient client = new PersistentConnectorClient();
            PreparedStatementParameter[] parameters = new
                PreparedStatementParameter[3];
            parameters[0] = new PreparedStatementParameter(names[0],
                Types.VARCHAR);
            parameters[1] = new PreparedStatementParameter(names[1],
                Types.VARCHAR);
            parameters[2] = new PreparedStatementParameter(
              ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER);
            Vector v = client.executeSqlQuery(sql, parameters, resourceName);
            return new Boolean(v.size() > 0);
        }
View Full Code Here

        String[] names = split(nodeName);
        try {
            PersistentConnectorClient client = new PersistentConnectorClient();
            PreparedStatementParameter[] parameters = new
                PreparedStatementParameter[4];
            parameters[0] = new PreparedStatementParameter(names[0],
                Types.VARCHAR);
            parameters[1] = new PreparedStatementParameter(names[1],
                Types.VARCHAR);
            parameters[2] = new PreparedStatementParameter(
                ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER);
            parameters[3] = new PreparedStatementParameter(Boolean.TRUE,
                Types.BOOLEAN);

            client.executeSql(insertName, parameters, resourceName);
        }
        catch (Exception e) {
View Full Code Here

        try {
            PersistentConnectorClient client = new PersistentConnectorClient();
            // to keep the foreign key happy
            Vector v = client.executeSqlQuery(selectNames,
                                              new PreparedStatementParameter[] {
                                              new
                                              PreparedStatementParameter(
                isRootNode ?
                EMPTY_STRING :
                nodeName, Types.VARCHAR),
                                              new PreparedStatementParameter(
                ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ), Types.INTEGER)
            }
                , resourceName);
            List orphans = new LinkedList();
            for (Iterator i = v.iterator(); i.hasNext(); ) {
                PreparedStatementResult result = (PreparedStatementResult) i.
                    next();
                String existingName = (String) result.get(
                    "CONFIG_PARAMETER_NAME");
                boolean exists = childrenNames.remove(existingName);
                if (!exists && ! (isRootNode && isEmptyString(existingName))) {
                    orphans.add(existingName);
                }
            }

            PreparedStatementParameter[] parameters2 = new
                PreparedStatementParameter[2];
            parameters2[0] = new PreparedStatementParameter(isRootNode ?
                EMPTY_STRING :
                nodeName, Types.VARCHAR);

            // inserts the new children names
            for (Iterator i = childrenNames.iterator(); i.hasNext(); ) {
                String childName = (String) i.next();
                client.executeSql(insertNames, new PreparedStatementParameter[] {
                                  new PreparedStatementParameter(isRootNode ?
                    EMPTY_STRING : nodeName, Types.VARCHAR),
                                  new PreparedStatementParameter(childName,
                    Types.VARCHAR),
                                  new PreparedStatementParameter(
                    ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                    Types.INTEGER),
                                  new PreparedStatementParameter(Boolean.TRUE,
                    Types.INTEGER)
                }
                    , resourceName);
            }
View Full Code Here

        try {
            PersistentConnectorClient client = new PersistentConnectorClient();

            client.executeSql(deleteValuesFromKey,
                              new PreparedStatementParameter[] {
                              new PreparedStatementParameter(nodeName,
                Types.VARCHAR),
                              new PreparedStatementParameter(
                ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER)
            }
                , resourceName);
            client.executeSql(deleteValuesFromValue,
                              new PreparedStatementParameter[] {
                              new PreparedStatementParameter(nodeName,
                Types.VARCHAR)
            }
                , resourceName);

            for (Iterator i = entries.keySet().iterator(); i.hasNext(); ) {
                String key = (String) i.next();
                String value = (String) entries.get(key);
                String timestamp = null;
                Timestamp ts = null;
                if (key.indexOf(" <<") != -1) {
                  timestamp = key.substring(key.indexOf(" <<") + 3);
                  key = key.substring(0, key.indexOf(" <<"));
                  if (timestamp.indexOf(">>") != -1) {
                    timestamp = timestamp.substring(0, timestamp.indexOf(">>"));
                  }
                }
              if (timestamp != null) {
                try {
                  ts = convertStringToTimestamp(timestamp);
                }
                catch (Throwable th) {
                  ts = new Timestamp(System.currentTimeMillis());
                }
              }
              else {
                ts = new Timestamp(System.currentTimeMillis());
              }
                // fix for oracle empty string problem
                if (key.length() == 0) {
                    key = EMPTY_STRING;
                }
                if (value.length() == 0) {
                    value = EMPTY_STRING;
                }

                try {
                  client.executeSql(insertValuesToKey, new PreparedStatementParameter[] {
                                    new PreparedStatementParameter(nodeName,
                      Types.VARCHAR),
                                    new PreparedStatementParameter(key,
                      Types.VARCHAR),
                                    new PreparedStatementParameter(new Integer(2),
                      Types.INTEGER),
                                    new PreparedStatementParameter(Boolean.TRUE,
                      Types.BOOLEAN)
                  }, resourceName);
                }
                catch (Exception ex) {
                  // dublicate key possible
                }
               
                client.executeSql(insertValuesToValue, new PreparedStatementParameter[] {
                    new PreparedStatementParameter(nodeName, Types.VARCHAR),
                    new PreparedStatementParameter(key, Types.VARCHAR),
                    new PreparedStatementParameter(value, Types.VARCHAR),
                    new PreparedStatementParameter(ts, Types.TIMESTAMP)
                }, resourceName);
            }
           
            return loadEntries(isUserNode, nodeName);
        }
View Full Code Here

        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
        try {
            Vector v = PersistentConnectorClient.executeSqlQuery(
                select,
                    new PreparedStatementParameter[] {
                    new PreparedStatementParameter(nodeName, Types.VARCHAR)
                } ,
                resourceName );
            Map entries = new HashMap();
            List list = new ArrayList();
            String donekey = "";
View Full Code Here

        try {
            PersistentConnectorClient client = new PersistentConnectorClient();
            PreparedStatementParameter[] parameters = new
                PreparedStatementParameter[2];
            parameters[0] = new PreparedStatementParameter(isRootNode ?
                EMPTY_STRING : nodeName, Types.VARCHAR);
            parameters[1] = new PreparedStatementParameter(
                ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER);

            Vector v = client.executeSqlQuery(sql, parameters, resourceName);
            Set childrenNames = new HashSet(v.size());
View Full Code Here

        String[] names = split(nodeName);
        try {
            PersistentConnectorClient client = new PersistentConnectorClient();
            client.executeSql(deleteValuesFromValue,
                              new PreparedStatementParameter[] {
                              new PreparedStatementParameter(nodeName,
                Types.VARCHAR)
            }
                , resourceName);
            client.executeSql(deleteValuesFromKey,
                              new PreparedStatementParameter[] {
                              new PreparedStatementParameter(nodeName,
                Types.VARCHAR),
                              new PreparedStatementParameter(
               ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER)
            }
                , resourceName);
            client.executeSql(deleteNode, new PreparedStatementParameter[] {
                              new PreparedStatementParameter(names[0],
                Types.VARCHAR),
                              new PreparedStatementParameter(names[1],
                Types.VARCHAR),
                              new PreparedStatementParameter(
               ( isUserNode.booleanValue()? USER_TYPE_NODE : SYSTEM_TYPE_NODE ),
                Types.INTEGER)
            }
                , resourceName);
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.jivalo.cnfmgr.persistent.PreparedStatementParameter

Copyright © 2018 www.massapicom. 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.