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.DefaultDirectoryBlobDeleteQuery.java

/**
 *   This method deletes defdirblob /*from w  ww  . j a  va  2  s  . c  o m*/
 *   @param conn - the connection
 *   @param directoryid - the directoryid
 *   @throws BaseDaoException - when error occurs
 *   Used as part of the transaction, skip LOW_PRIORITY
 **/
public void run(Connection conn, String directoryid) throws BaseDaoException {
    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete from defdirblob where directoryid=" + directoryid + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing defdirblob query ", e);
    }
}

From source file:dao.DeleteColTopicAttrPerCollabrumQuery.java

/**
 * Delete all collabrum topics in a collabrum 
 * @param conn the connection//from w  ww  .  j  a v a 2s  .  c  om
 * @param tidStr the tid
 * @exception BaseDaoException
 */
public void run(Connection conn, String tidStr) throws BaseDaoException {

    if ((conn != null && tidStr != null)) {
        //Integer tid = new Integer(tidStr);
        try {
            PreparedStatement stmt = conn
                    .prepareStatement("delete from colltopicattr 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.PersonalinfoDeleteQuery.java

/**
 *   This method deletes personalinfo settings of the user 
 *   @param conn - the connection//from  w  w w.  ja v  a2s .c  om
 *   @param loginid - the loginid
 *   @throws BaseDaoException - when error occurs
 **/
public void run(Connection conn, String loginid) throws BaseDaoException {
    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete LOW_PRIORITY from usertab where loginid=" + loginid + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing usertab query ", e);
    }
}

From source file:dao.CollabrumDefaultDeleteQuery.java

/**
 *   This method deletes defcarryon /*ww  w.  j  a  v a2  s  . com*/
 *   @param conn - the connection
 *   @param loginid - the loginid
 *   @throws BaseDaoException - when error occurs
 *   Used as part of the transaction, skip LOW_PRIORITY
 **/
public void run(Connection conn, String collabrumid) throws BaseDaoException {
    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete from defcollblob where collabrumid=" + collabrumid + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing defcollblob query ", e);
    }
}

From source file:dao.DirectoryScopeDeleteQuery.java

/**
 * This method is used to delete scope for a given directory
 * This method should delete only one row 
 * @param conn the connection/* 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 {

    /**
     * dont use low_priority for a query that is in transaction.
     */
    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete from dirscope where directoryid=" + did + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error occured while executing db query, delete from dirscope where directoryid=" + did, e);
    }
}

From source file:dao.FriendAddQuery.java

public void run(Connection conn, String loginId, String guestId) throws BaseDaoException {

    try {/*from w ww.  ja  v  a2 s.c  o m*/
        PreparedStatement stmt = conn
                .prepareStatement("insert into hdfriends values (" + loginId + ", " + guestId + ")");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing hdfriends addquery", e);
        throw new BaseDaoException("Error occured while executing hdfriends addquery", e);
    }
}

From source file:dao.CollabrumDefaultAddQuery.java

/**
 *  Adds keywords for a given user/*www .  j av  a 2  s  .  c  om*/
 *  @param conn - the connection
 *  @param yourKeyword - your keywords
 *  @param loginid - the loginid
 *  @throws BaseDaoException - when error occurs
 **/
public void run(Connection conn, String entryid, String collabrumId) throws BaseDaoException {

    Long collId = new Long(collabrumId);
    try {
        PreparedStatement stmt = conn
                .prepareStatement("insert into defcollblob values(" + collId + ", '" + entryid + "')");
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing CollabrumDefaultAddQuery ", e);
        throw new BaseDaoException("Error occured while executing CollabrumDefaultAddQuery ", e);
    }
}

From source file:dao.CollAllMembersDeleteQuery.java

/**
  * This method is invoked when collabrum (network blog) is deleted
  * All the members in that social network are deleted
  * @param conn - the connection/*w  w w  .j  av  a  2 s. c  o  m*/
  * @param collabrumId - the collabrumId
  * @throws BaseDaoException - when an exception occurs
  **/

public void run(Connection conn, String collabrumId) throws BaseDaoException {

    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete from collmembers where collabrumId=" + collabrumId + "");
        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.HdprofileDeleteQuery.java

/**
 *   This method deletes profile of the user 
 *   @param conn - the connection//from w  w w. j a va 2 s . c om
 *   @param loginid - the loginid
 *   @throws BaseDaoException - when error occurs
 **/
public void run(Connection conn, String loginid) throws BaseDaoException {
    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete LOW_PRIORITY from hdprofile where loginid=" + loginid + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing hdprofile query ", e);
    }
}

From source file:dao.DeleteDirCopyQuery.java

/**
 * This method deletes directory//from   w  w  w.  j  ava  2  s.  c  o m
 * This method can be invoked only either the admins or the authors of this directory
 * @param conn the connection
 * @param cid the category id
 * @param ownerid the id of the owner
 * @exception BaseDaoException
 */
public void run(Connection conn, String directoryId) throws BaseDaoException {

    try {
        PreparedStatement stmt = conn
                .prepareStatement("delete from dircopy where directoryid=" + directoryId + " limit 1");
        stmt.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error executing db query, delete from dircopy where directoryid=" + directoryId, e);
    }
}