Examples of JDBCPreparedStatement


Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.extensions.ApplicationShortcutDatabase#getShortcut(int)
     */
    public ApplicationShortcut getShortcut(int shortcutId) throws Exception {
        JDBCPreparedStatement ps = db.getStatement("getShortcut.select");
        ps.setInt(1, shortcutId);
        try {
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return buildShortcut(rs);
                } else {
                    return null;
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

        ApplicationShortcut sc = getShortcut(shortcutId);
        if (sc == null) {
            throw new Exception("Application shortcut " + shortcutId + " does not exist.");
        }

        JDBCPreparedStatement ps = db.getStatement("deleteShortcuts.delete.favorite");

        // Delete a favorite
        try {
            ps.setString(1, String.valueOf(shortcutId));
            ps.setInt(2, ApplicationsPlugin.APPLICATION_SHORTCUT_RESOURCE_TYPE_ID);
            ps.execute();
            ps.reset();
        } finally {
            ps.releasePreparedStatement();
        }

        // Delete a shortcut
        ps = db.getStatement("deleteShortcuts.delete.shortcut");
        try {
            ps.setInt(1, shortcutId);
            ps.execute();
            ps.reset();
        } finally {
            ps.releasePreparedStatement();
        }

        // Delete all parameters for a shortcut
        ps = db.getStatement("deleteShortcuts.delete.shortcutParameters");
        try {
            ps.setInt(1, shortcutId);
            ps.execute();
            ps.reset();
        } finally {
            ps.releasePreparedStatement();
        }

        return sc;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

        return new DefaultApplicationShortcut(realmId, resourceId, name, description, dateCreated, dateAmended,
                        application, settings, autoStart);
    }

    private Map<String, String> getParameters(int resourceId) throws SQLException, ClassNotFoundException {
        JDBCPreparedStatement ps2 = db.getStatement("buildShortcut.select.parameters");
        ps2.setInt(1, resourceId);
        Map<String,String> settings = new HashMap<String,String>();
        try {
            ResultSet rs2 = ps2.executeQuery();
            try {
                while (rs2.next()) {
                    settings.put(rs2.getString("parameter"), rs2.getString("value"));
                }

            } finally {
                rs2.close();
            }
        } finally {
            ps2.releasePreparedStatement();
        }
        return settings;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

    /* (non-Javadoc)
     * @see com.adito.applications.ApplicationShortcutDatabase#getShortcuts(int)
     */
    public List<ApplicationShortcut> getShortcuts(int realmID) throws Exception {

        JDBCPreparedStatement ps = db.getStatement("getShortcuts.realm.selectAll");
        Vector<ApplicationShortcut> v = new Vector<ApplicationShortcut>();
        try {
            ps.setInt(1, realmID);
            ResultSet rs = ps.executeQuery();
            try {
                while (rs.next()) {
                    v.add(buildShortcut(rs));
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }

        return v;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

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

Examples of com.adito.jdbc.JDBCPreparedStatement

     *      int)
     */
    public void updateTunnel(int id, String name, String description, int type, boolean autoStart, String transport,
                    String username, int sourcePort, HostService destination, String sourceInterface) throws Exception {

        JDBCPreparedStatement ps2 = db.getStatement("updateTunnel.update");
        try {
            ps2.setString(1, name);
            ps2.setString(2, description);
            ps2.setInt(3, type);
            ps2.setInt(4, autoStart ? 1 : 0);
            ps2.setString(5, transport);
            ps2.setString(6, username == null ? "" : username);
            ps2.setInt(7, sourcePort);
            ps2.setInt(8, destination.getPort());
            ps2.setString(9, destination.getHost());
            ps2.setString(10, sourceInterface);
            Calendar now = Calendar.getInstance();
            ps2.setString(11, db.formatTimestamp(now));
            ps2.setInt(12, id);
            ps2.execute();
        } finally {
            ps2.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * @see com.adito.tunnels.TunnelDatabase#createTunnel(int, java.lang.String, java.lang.String, int, boolean, java.lang.String, java.lang.String, int, com.adito.boot.HostService, java.lang.String)
     */
    public Tunnel createTunnel(int realmID, String name, String description, int type, boolean autoStart, String transport, String username,
                    int sourcePort, HostService destination, String sourceInterface) throws Exception {

        JDBCPreparedStatement ps2 = db.getStatement("createTunnel.insert");
        try {
            ps2.setString(1, name);
            ps2.setString(2, description);
            ps2.setInt(3, type);
            ps2.setInt(4, autoStart ? 1 : 0);
            ps2.setString(5, transport);
            ps2.setString(6, username == null ? "" : username);
            ps2.setInt(7, sourcePort);
            ps2.setInt(8, destination.getPort());
            ps2.setString(9, destination.getHost());
            ps2.setString(10, sourceInterface);
            Calendar now = Calendar.getInstance();
            ps2.setString(11, db.formatTimestamp(now));
            ps2.setString(12, db.formatTimestamp(now));
            ps2.setInt(13, realmID);
            ps2.execute();
            return new DefaultTunnel(realmID, name, description, db.getLastInsertId(ps2, "createTunnel.lastInsertId"), type, autoStart,
                            transport, username, sourcePort, destination, sourceInterface, now, now);

        } finally {
            ps2.releasePreparedStatement();
        }
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

    public Tunnel removeTunnel(int id) throws Exception {
        Tunnel t = getTunnel(id);
        if (t == null) {
            throw new Exception("No tunnel with " + id);
        }
        JDBCPreparedStatement ps = db.getStatement("removeTunnel.deleteFavorite");
        try {
            ps.setInt(1, TunnelPlugin.SSL_TUNNEL_RESOURCE_TYPE_ID);
            ps.setString(2, String.valueOf(id));
            ps.execute();
        } finally {
            ps.releasePreparedStatement();
        }
        ps = db.getStatement("removeTunnel.deleteTunnel");
        try {
            ps.setInt(1, id);
            ps.execute();
        } finally {
            ps.releasePreparedStatement();
        }
        return t;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.security.SystemDatabase#getTunnels(java.lang.String)
     */
    public List<Tunnel> getTunnels() throws Exception {
        JDBCPreparedStatement ps = db.getStatement("getTunnels.select");
        List<Tunnel> v = new ArrayList<Tunnel>();
        try {
            ResultSet rs = ps.executeQuery();
            try {
                while (rs.next()) {
                    v.add(buildTunnel(rs));
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
        return v;
    }
View Full Code Here

Examples of com.adito.jdbc.JDBCPreparedStatement

     * (non-Javadoc)
     *
     * @see com.adito.security.SystemDatabase#getTunnel(int)
     */
    public Tunnel getTunnel(int id) throws Exception {
        JDBCPreparedStatement ps = db.getStatement("getTunnel.select.id");
        ps.setInt(1, id);
        try {
            ResultSet rs = ps.executeQuery();
            try {
                if (rs.next()) {
                    return buildTunnel(rs);
                }
            } finally {
                rs.close();
            }
        } finally {
            ps.releasePreparedStatement();
        }
        return null;
    }
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.