Example usage for java.sql PreparedStatement executeUpdate

List of usage examples for java.sql PreparedStatement executeUpdate

Introduction

In this page you can find the example usage for java.sql PreparedStatement executeUpdate.

Prototype

int executeUpdate() throws SQLException;

Source Link

Document

Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.

Usage

From source file:dao.PblogMessageDeleteQuery.java

/**
 * Deletes a pblog message/*from   w  w w . ja v a2 s. co  m*/
 * @param conn the connection
 * @param ridStr the reply id
 * @param memberid the id of the member
 * @param isAdmin - true if the user is a DiaryAdmin or a Moderator for this pblog
 * @exception BaseDaoException
 */
public void run(Connection conn, String ridStr, String memberid, boolean isAdmin) throws BaseDaoException {

    /**
          *  If user is an admin/organizer, don't check ownerid
          */
    try {
        if (isAdmin) {
            String query = "delete LOW_PRIORITY from pblogmessages where rid=" + ridStr + " limit 1";
            PreparedStatement stmt = conn.prepareStatement(query);
            stmt.executeUpdate();
        } else {
            String query = "delete from pblogmessages where rid=" + ridStr + " and ownerid='" + memberid
                    + "' limit 1";
            PreparedStatement stmt = conn.prepareStatement(query);
            stmt.executeUpdate();
        }
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error in query, delete from pblogmessages where rid=" + ridStr + " and ownerid=" + memberid,
                e);
    }
}

From source file:dao.MykeywordsDeleteQuery.java

/**
 * Used for deleting mykeywords//  w  w w.  j av  a  2  s .co m
 * @param conn - the connection
 * @param loginid - the login id
 * This query is being used as part of the transaction. Don't put this in the low-priority mode.
 */
public void run(Connection conn, String loginid) throws BaseDaoException {
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from mykeywords where loginid=" + loginid + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while deleting mykeywords ", e);
    }
}

From source file:dao.DeleteColMessagesIndexQuery.java

/**
 * This method is used to delete a rid in a collmessages_ind
 * @param conn the connection//from w  w  w .  j  a va  2 s  .c om
 * @param rid the rid
 * @exception BaseDaoException
 */
public void run(Connection conn, String rid) throws BaseDaoException {

    try {
        PreparedStatement stmt = conn.prepareStatement("delete from collmessages_ind where rid=" + rid + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error while executing db query, delete from collmessages_ind where rid=" + rid, e);
    }
}

From source file:dao.DeleteColMessageAttrPerTidQuery.java

/**
 * Deletes all collabrum message belonging to tid 
 * @param conn the connection/*from  w  ww  .ja  v  a 2s.  c  om*/
 * @param tidStr the tid
 * @param isAdmin - true if the user is a DiaryAdmin or a Moderator for this collabrum
 * @exception BaseDaoException
 */
public void run(Connection conn, String tidStr) throws BaseDaoException {

    //Integer tid = new Integer(tidStr);
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from collmsgattr where tid=" + tidStr + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing db query ", e);
        throw new BaseDaoException("Error occured while executing db query ", e);
    }
}

From source file:dao.DeleteColMessagePerTidQuery.java

/**
 * Deletes all collabrum message belonging to tid 
 * @param conn the connection/*from   w  ww  . j a v  a2s  .com*/
 * @param tidStr the tid
 * @param isAdmin - true if the user is a DiaryAdmin or a Moderator for this collabrum
 * @exception BaseDaoException
 */
public void run(Connection conn, String tidStr) throws BaseDaoException {

    //Integer tid = new Integer(tidStr);
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from collmessages where tid=" + tidStr + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing db query ", e);
        throw new BaseDaoException("Error occured while executing db query ", e);
    }
}

From source file:dao.DirBlobDeleteAllQuery.java

/**
 * This query deletes all authors matching this directoryid
 * @param conn the connection/*from  w ww. j a  v a2  s  .  com*/
 * @param did the directory id
 * @exception BaseDaoException
 */
public void run(Connection conn, String did) throws BaseDaoException {

    /**
     * don't use low priority for a query that is in a transaction
     */
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from dirblob where directoryid=" + did + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error executing delete from dirblob where directoryid=" + did, e);
    }
}

From source file:dao.DeleteColTrafficPerCollabrumQuery.java

/**
 * Delete all collabrum traffic//from  ww w  .  j  a v a2 s. co m
 * @param conn the connection
 * @param collabrumId the collabrumId
 * @exception BaseDaoException
 */
public void run(Connection conn, String collabrumId) throws BaseDaoException {
    Integer cid = new Integer(collabrumId);
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from colltraffic where collabrumid=" + cid + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing db query ", e);
        throw new BaseDaoException("Error occured while executing db query ", e);
    }
}

From source file:dao.DeleteColTopicsIndexQuery.java

/**
 * Deletes all collabrum message belonging to tid 
 * @param conn the connection//  w  w  w  .j  ava2 s  .c  o  m
 * @param tidStr the tid
 * @param isAdmin - true if the user is a DiaryAdmin or a Moderator for this collabrum
 * @exception BaseDaoException
 */
public void run(Connection conn, String tidStr) throws BaseDaoException {

    //Integer tid = new Integer(tidStr);
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from colltopics_ind where tid=" + tidStr + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing db query ", e);
        throw new BaseDaoException("Error occured while executing db query ", e);
    }
}

From source file:dao.DirCollDeleteQuery.java

/**
 * @param conn the connection/*  w w  w  . j a v a2s  .co  m*/
 * @param cid the category id
 * @param ownerid the id of the owner
 * @exception BaseDaoException
 */
public void run(Connection conn, String cid) throws BaseDaoException {

    /**
     * don't use LOW_PRIORITY for queries that are in transaction
     */
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from dircoll where collabrumid=" + cid + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error while executing db query, delete from collabrum where collabrumid=" + cid, e);
    }
}

From source file:dao.DirDeleteChildQuery.java

/**
 * This query deletes all authors matching this directoryid
 * @param conn the connection/*from  w w  w .j a  va  2s.c  o m*/
 * @param did the directory id
 * @exception BaseDaoException
 */
public void run(Connection conn, String did) throws BaseDaoException {

    /**
     * don't use low priority for a query that is in a transaction
     */
    try {
        PreparedStatement stmt = conn.prepareStatement("delete from dirtree where directoryid=" + did + "");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing delete from dirtree where directoryid=" + did,
                e);
    }
}