Examples of JDBCPreparedStatement


Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.webforwards.WebForwardDatabase#getWebForwards()
     */
    public List<WebForward> getWebForwards() throws Exception {
        JDBCPreparedStatement ps = db.getStatement("getWebForwards.select.allTypes");
        try {
            ResultSet rs = ps.executeQuery();
            try {
                List<WebForward> v = new ArrayList<WebForward>();
                while (rs.next()) {
                    v.add(buildWebForward(rs));
                }
                return v;
            } finally {
                if (rs != null) {
                    rs.close();
                }
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

    /* (non-Javadoc)
     * @see com.adito.webforwards.WebForwardDatabase#getWebForward(java.lang.String, int)
     */
    public WebForward getWebForward(String name, int realmID) throws Exception {
        JDBCPreparedStatement ps = null;
        try {
            ps = db.getStatement("getWebForward.select.name");
            ps.setString(1, name);
            ps.setInt(2, realmID);
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return buildWebForward(rs);
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
        return null;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.webforwards.WebForwardDatabase#reverseProxyPathExists(java.lang.String)
     */
    public boolean reverseProxyPathExists(String path) throws Exception {
        JDBCPreparedStatement ps = null;
        try {
            ps = db.getStatement("createWebForward.reverseProxy.path.exists");
            ps.setString(1, path);
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return true;
                } else {
                    return false;
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     *
     * @see com.adito.webforwards.WebForwardDatabase#reverseProxyPathExists(java.lang.String,
     *      int)
     */
    public boolean reverseProxyPathExists(String path, int webforward_id) throws Exception {
        JDBCPreparedStatement ps = null;
        try {
            ps = db.getStatement("createWebForward.reverseProxy.path.already.exists");
            ps.setString(1, path);
            ps.setInt(2, webforward_id);
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return true;
                } else {
                    return false;
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.webforwards.WebForwardDatabase#createWebForward(com.adito.webforwards.WebForward)
     */
    public WebForward createWebForward(WebForward webForward) throws Exception {
        JDBCPreparedStatement ps = db.getStatement("createWebForward.insert");

        /*
         * For this method, we could get errors when inserting proxy paths (if
         * path already exists). To deal with this the whole operation is run as
         * a transaction.
         */
        ps.startTransaction();

        try {
            int id = -1;
            ps.setString(1, webForward.getDestinationURL());
            ps.setInt(2, webForward.getType());
            ps.setString(3, webForward.getResourceName());
            ps.setString(4, webForward.getResourceDescription());
            ps.setString(5, webForward.getCategory());
            ps.setInt(6, webForward.isAutoStart() ? 1 : 0);
            Calendar now = Calendar.getInstance();
            ps.setString(7, db.formatTimestamp(now));
            ps.setString(8, db.formatTimestamp(now));
            ps.setInt(9, webForward.getRealmID());
            ps.execute();
            webForward.setResourceId(id = db.getLastInsertId(ps, "createWebForward.lastInsertId"));

            if (webForward instanceof ReverseProxyWebForward) {
                ps = db.getStatement(ps, "createWebForward.reverseProxy.insert");
                StringTokenizer t = new StringTokenizer(((ReverseProxyWebForward) webForward).getPaths(), "\n\r");
                while (t.hasMoreTokens()) {
                    String path = t.nextToken();
                    ps.setString(1, path);
                    ps.setInt(2, id);
                    ps.execute();
                    ps.reset();
                }
                ps = db.getStatement(ps, "createWebForward.reverseProxyOptions.insert");
                ps.setInt(1, webForward.getResourceId());
                ps.setString(2, ((ReverseProxyWebForward) webForward).getAuthenticationUsername());
                ps.setString(3, Util.emptyWhenNull(((ReverseProxyWebForward) webForward).getAuthenticationPassword()));
                ps.setString(4, ((ReverseProxyWebForward) webForward).getPreferredAuthenticationScheme());
                ps.setInt(5, ((ReverseProxyWebForward) webForward).getActiveDNS() ? 1 : 0);
                ps.setString(6, ((ReverseProxyWebForward) webForward).getHostHeader());
                ps.setString(7, ((ReverseProxyWebForward) webForward).getFormType());
                ps.setString(8, ((ReverseProxyWebForward) webForward).getFormParameters());
                ps.setString(9, ((ReverseProxyWebForward) webForward).getCharset());
                ps.execute();
            }

            if (webForward instanceof ReplacementProxyWebForward) {
                ps = db.getStatement(ps, "createWebForward.replacementProxyOptions.insert");
                ps.setInt(1, webForward.getResourceId());
                ps.setString(2, ((ReplacementProxyWebForward) webForward).getAuthenticationUsername());
                ps.setString(3, Util.emptyWhenNull(((ReplacementProxyWebForward) webForward).getAuthenticationPassword()));
                ps.setString(4, ((ReplacementProxyWebForward) webForward).getPreferredAuthenticationScheme());
                ps.setString(5, ((ReplacementProxyWebForward) webForward).getEncoding());
                ps.setString(6, ((ReplacementProxyWebForward) webForward).getRestrictToHosts().getAsPropertyText());
                ps.setString(7, ((ReplacementProxyWebForward) webForward).getFormType());
                ps.setString(8, ((ReplacementProxyWebForward) webForward).getFormParameters());
                ps.execute();
            }

            ps.commit();
        } catch (Exception e) {
            ps.rollback();
            throw e;
        } finally {
            ps.releasePreparedStatement();
            ps.endTransaction();
        }
        return getWebForward(webForward.getResourceId());
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.webforwards.WebForwardDatabase#updateWebForward(com.adito.webforwards.WebForward)
     */
    public void updateWebForward(WebForward webForward) throws Exception {
        JDBCPreparedStatement ps = db.getStatement("updateWebForward.update");

        /*
         * For this method, we could get errors when inserting proxy paths (if
         * path already exists). To deal with this the whole operation is run as
         * a transaction.
         */
        ps.startTransaction();

        try {

            ps.setInt(1, webForward.getType());
            ps.setString(2, webForward.getResourceName());
            ps.setString(3, webForward.getDestinationURL());
            ps.setString(4, webForward.getResourceDescription());
            ps.setString(5, webForward.getCategory());
            ps.setInt(6, webForward.isAutoStart() ? 1 : 0);
            Calendar c = Calendar.getInstance();
            ps.setString(7, db.formatTimestamp(c));
            ps.setInt(8, webForward.getResourceId());
            ps.execute();

            if (webForward instanceof ReverseProxyWebForward) {
                ps = db.getStatement(ps, "updateWebForward.reverseProxy.delete");
                ps.setInt(1, webForward.getResourceId());
                ps.execute();
                ps = db.getStatement(ps, "updateWebForward.reverseProxy.insert");
                StringTokenizer t = new StringTokenizer(((ReverseProxyWebForward) webForward).getPaths(), "\n\r");
                while (t.hasMoreTokens()) {
                    String path = t.nextToken();
                    ps.setString(1, path);
                    ps.setInt(2, webForward.getResourceId());
                    ps.execute();
                    ps.reset();
                }
                ps = db.getStatement(ps, "updateWebForward.reverseProxyOptions.update");
                ps.setString(1, ((ReverseProxyWebForward) webForward).getAuthenticationUsername());
                ps.setString(2, ((ReverseProxyWebForward) webForward).getAuthenticationPassword());
                ps.setString(3, ((ReverseProxyWebForward) webForward).getPreferredAuthenticationScheme());
                ps.setInt(4, ((ReverseProxyWebForward) webForward).getActiveDNS() ? 1 : 0);
                ps.setString(5, ((ReverseProxyWebForward) webForward).getHostHeader());
                ps.setString(6, ((ReverseProxyWebForward) webForward).getFormType());
                ps.setString(7, ((ReverseProxyWebForward) webForward).getFormParameters());
                ps.setString(8, ((ReverseProxyWebForward) webForward).getCharset());
                ps.setInt(9, webForward.getResourceId());

                ps.execute();
            }

            if (webForward instanceof ReplacementProxyWebForward) {
                ps = db.getStatement(ps, "updateWebForward.replacementProxyOptions.update");
                ps.setString(1, ((ReplacementProxyWebForward) webForward).getEncoding());
                ps.setString(2, ((ReplacementProxyWebForward) webForward).getRestrictToHosts().getAsPropertyText());
                ps.setString(3, ((ReplacementProxyWebForward) webForward).getAuthenticationUsername());
                ps.setString(4, ((ReplacementProxyWebForward) webForward).getAuthenticationPassword());
                ps.setString(5, ((ReplacementProxyWebForward) webForward).getPreferredAuthenticationScheme());
                ps.setString(6, ((ReplacementProxyWebForward) webForward).getFormType());
                ps.setString(7, ((ReplacementProxyWebForward) webForward).getFormParameters());
                ps.setInt(8, webForward.getResourceId());
                ps.execute();
            }

            ps.commit();
        } catch (Exception e) {
            ps.rollback();
            throw e;
        } finally {
            ps.releasePreparedStatement();
            ps.endTransaction();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

    public WebForward deleteWebForward(int webForwardId) throws Exception {
        WebForward wf = getWebForward(webForwardId);
        if (wf == null) {
            throw new Exception("No web forward with id of " + webForwardId);
        }
        JDBCPreparedStatement ps = db.getStatement("deleteWebForward.delete.favorites");
        try {
            ps.setInt(1, WebForwardPlugin.WEBFORWARD_RESOURCE_TYPE_ID);
            ps.setString(2, String.valueOf(webForwardId));
            ps.execute();
        } finally {
            ps.releasePreparedStatement();
        }
        ps = db.getStatement("deleteWebForward.delete.webForward");
        try {
            ps.setInt(1, webForwardId);
            ps.execute();
        } finally {
            ps.releasePreparedStatement();
        }
        if (wf.getType() == WebForward.TYPE_REPLACEMENT_PROXY) {
            ps = db.getStatement("deleteWebForward.delete.replacementProxy.options");
            try {
                ps.setInt(1, wf.getResourceId());
                ps.execute();
            } finally {
                ps.releasePreparedStatement();
            }
        }
        if (wf.getType() == WebForward.TYPE_PATH_BASED_REVERSE_PROXY || wf.getType() == WebForward.TYPE_HOST_BASED_REVERSE_PROXY) {
            ps = db.getStatement("deleteWebForward.delete.reverseProxy");
            try {
                ps.setInt(1, wf.getResourceId());
                ps.execute();
            } finally {
                ps.releasePreparedStatement();
            }
            ps = db.getStatement("deleteWebForward.delete.reverseProxy.options");
            try {
                ps.setInt(1, wf.getResourceId());
                ps.execute();
            } finally {
                ps.releasePreparedStatement();
            }
        }
        return wf;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     *      boolean, boolean, boolean)
     */
    public NetworkPlace createNetworkPlace(String scheme, String shortName, String description, String host, String uri, int port,
                    String username, String password, boolean readOnly, boolean allowResursive, boolean noDelete, boolean showHidden, boolean autoStart, int realmID)
                    throws Exception {
        JDBCPreparedStatement ps = db.getStatement("createNetworkPlace.insert");
        try {
            ps.setString(1, scheme);
            ps.setString(2, host);
            ps.setString(3, uri);
            ps.setInt(4, port);
            ps.setString(5, username);
            ps.setString(6, password);
            ps.setString(7, shortName);
            ps.setString(8, description);
            ps.setInt(9, readOnly ? 1 : 0);
            ps.setInt(10, allowResursive ? 1 : 0);
            ps.setInt(11, noDelete ? 1 : 0);
            ps.setInt(12, showHidden ? 1 : 0);
            ps.setInt(13, autoStart ? 1 : 0);
            Calendar now = Calendar.getInstance();
            ps.setString(14, db.formatTimestamp(now));
            ps.setString(15, db.formatTimestamp(now));
            ps.setInt(16, realmID);
            ps.execute();
            int id = db.getLastInsertId(ps, "createNetworkPlace.lastInsertId");
            return this.getNetworkPlace(id);
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.security.SystemDatabase#getNetworkPlace(int)
     */
    public NetworkPlace getNetworkPlace(int resourceId) throws Exception {
        JDBCPreparedStatement ps = null;
        ps = db.getStatement("getNetworkPlace.select");
        ps.setInt(1, resourceId);
        try {
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return buildNetworkPlace(rs);
                }
                return null;
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

    /* (non-Javadoc)
     * @see com.adito.networkplaces.NetworkPlaceDatabase#getNetworkPlace(java.lang.String, int)
     */
    public NetworkPlace getNetworkPlace(String name, int realmID) throws Exception {
        JDBCPreparedStatement ps = null;
        ps = db.getStatement("getNetworkPlace.select.name");
        ps.setString(1, name);
        ps.setInt(2, realmID);
        try {
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return buildNetworkPlace(rs);
                }
                return null;
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
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.