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

/**
 * This method is not called by spring./*from  ww  w. j a  v a 2 s  . co m*/
 * This method adds userstags to the photos
 * @param conn the connection passed to this.
 * @param collabrumid the directory id
 * @param usertags usertags for photos
 * @exception BaseDaoException
 */
public void run(Connection conn, String collabrumid, String usertags, String entryId) throws BaseDaoException {
    String stmt = "insert into collblobtags values (" + collabrumid + ", " + entryId + ", '" + usertags + "')";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing inserting into collblobtags" + stmt, e);
    }
}

From source file:dao.DirCopyAddQuery.java

/**
 * This method is not called by spring./*from ww  w .j ava  2s . c om*/
 * This method adds an admin into this directory
 * @param conn the connection passed to this.
 * @param dirid the directory id
 * @param ownerid the author id for this directory
 * @exception BaseDaoException
 */
public void run(Connection conn, String dirid, String loginid) throws BaseDaoException {
    String stmt = "insert into dircopy values (" + dirid + ", " + loginid + ")";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing inserting into dircopy" + stmt, e);
    }
}

From source file:dao.DirMoveAddQuery.java

/**
 * This method is not called by spring.//from  w  ww  . j a  v  a 2s . c  om
 * This method adds an admin into this directory
 * @param conn the connection passed to this.
 * @param dirid the directory id
 * @param ownerid the author id for this directory
 * @exception BaseDaoException
 */
public void run(Connection conn, String dirid, String loginid) throws BaseDaoException {
    String stmt = "insert into dirmove values(" + dirid + ", " + loginid + ")";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing insert into dirmove query, " + stmt, e);
    }
}

From source file:dao.DirBlobTagsAddQuery.java

/**
 * This method is not called by spring./*  w  ww . java2s.co  m*/
 * This method adds userstags to the photos
 * @param conn the connection passed to this.
 * @param directoryid the directory id
 * @param usertags usertags for photos
 * @param title title for photos
 * @exception BaseDaoException
 */
public void run(Connection conn, String directoryid, String usertags, String entryId) throws BaseDaoException {
    String stmt = "insert into dirblobtags values (" + directoryid + ", " + entryId + ", '" + usertags + "')";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing inserting into dirblobtags" + stmt, e);
    }
}

From source file:dao.PblogTagAddQuery.java

/**
 * This method is not called by spring./*w w  w .  ja  v a  2  s.  c om*/
 * This method adds userstags to the photos
 * @param conn the connection passed to this.
 * @param directoryid the directory id
 * @param usertags usertags for photos
 * @param title title for photos
 * @exception BaseDaoException
 */
public void run(Connection conn, String ownerId, String tid, String usertags) throws BaseDaoException {
    String stmt = "insert into pblogtags values (" + ownerId + ", " + tid + ", '" + usertags + "')";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing inserting into pblogtags" + stmt, e);
    }
}

From source file:dao.PblogTopicNpAddQuery.java

/**
 * This method is not called by spring./*  w  w w  .j  a  v  a2 s . c o m*/
 * This method adds an entry to np table
 * @param conn the connection passed to this.
 * @param userId userId
 * @param tid tid
 * @exception BaseDaoException
 */
public void run(Connection conn, String ownerId, String tid, String userLogin) throws BaseDaoException {
    String stmt = "insert into pblogtopics_np values (" + tid + ", '" + userLogin + "', " + ownerId
            + ", CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP())";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error inserting entry in, pblogtopics_np" + stmt, e);
    }
}

From source file:dao.YourkeywordsAddQuery.java

/**
 *  Adds keywords for a given user/*from w  w w  .  j ava2  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 yourKeyword, String loginid) throws BaseDaoException {

    try {
        String query = "insert into yourkeywords values(" + loginid + ", '" + yourKeyword + "')";
        PreparedStatement stmt = conn.prepareStatement(query);
        stmt.executeUpdate();
    } catch (Exception e) {
        logger.warn("Error occured while executing YourkeywordsAddQuery ", e);
        throw new BaseDaoException("Error occured while executing YourkeywordsAddQuery ", e);
    }
}

From source file:com.stratelia.webactiv.util.DBUtil.java

protected static int getMaxId(Connection privateConnection, String tableName, String idName)
        throws SQLException {
    // tentative d'update
    SilverTrace.debug("util", "DBUtil.getNextId", "dBName = " + tableName);
    try {//from ww  w .j  av  a 2  s .  co  m
        int max = updateMaxFromTable(privateConnection, tableName);
        privateConnection.commit();
        return max;
    } catch (Exception e) {
        // l'update n'a rien fait, il faut recuperer une valeur par defaut.
        // on recupere le max (depuis la table existante du composant)
        SilverTrace.debug("util", "DBUtil.getNextId",
                "impossible d'updater, if faut recuperer la valeur initiale", e);
    }
    int max = getMaxFromTable(privateConnection, tableName, idName);
    PreparedStatement createStmt = null;
    try {
        // on enregistre le max
        String createStatement = "INSERT INTO UniqueId (maxId, tableName) VALUES (?, ?)";
        createStmt = privateConnection.prepareStatement(createStatement);
        createStmt.setInt(1, max);
        createStmt.setString(2, tableName.toLowerCase());
        createStmt.executeUpdate();
        privateConnection.commit();
        return max;
    } catch (Exception e) {
        // impossible de creer, on est en concurence, on reessaye l'update.
        SilverTrace.debug("util", "DBUtil.getNextId", "impossible de creer, if faut reessayer l'update", e);
        rollback(privateConnection);
    } finally {
        close(createStmt);
    }
    max = updateMaxFromTable(privateConnection, tableName);
    privateConnection.commit();
    return max;
}

From source file:dao.DirUpdateChildQuery.java

/**
 * This method is not called by spring./*from  w ww . j  a  v a  2s  . co  m*/
 * This method updates dirtree for this directory
 * @param conn the connection passed to this.
 * @param dirid the directory id
 * @param parentid the parent id for this directory
 * @exception BaseDaoException
 */
public void run(Connection conn, String dirid, String parentid) throws BaseDaoException {
    String stmt = null;
    try {
        stmt = "update dirtree set parentid=" + parentid + " where directoryid=" + dirid + "";
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing dirtree updateQuery(), " + stmt, e);
    }
}

From source file:dao.CarryonHitsAddQuery.java

/**
 * This method is not called by spring.//from  w ww .  j  ava2s.  co  m
 * This method adds userstags to the photos
 * @param conn the connection passed to this.
 * @param collabrumid the directory id
 * @param usertags usertags for photos
 * @exception BaseDaoException
 */
public void run(Connection conn, String loginid, String entryid, String btitle, String hits)
        throws BaseDaoException {
    String stmt = "insert into carryonhits values (" + loginid + ", " + entryid + ", '" + btitle + "', " + hits
            + ")";
    try {
        PreparedStatement query = conn.prepareStatement(stmt);
        query.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing inserting into carryonhits" + stmt, e);
    }
}