Java Utililty Methods SQL PreparedStatement

List of utility methods to do SQL PreparedStatement

Description

The list of methods to do SQL PreparedStatement are organized into topic(s).

Method

voidaddBatch(PreparedStatement prepStmt)
add Batch
try {
    prepStmt.addBatch();
} catch (SQLException sqle) {
    sqle.getNextException().printStackTrace();
    throw new RuntimeException(sqle);
voidaddValuesToPreparedStatement(PreparedStatement preparedStatement, List values)
add Values To Prepared Statement
int i = 1;
for (Iterator iter = values.iterator(); iter.hasNext(); i++) {
    Object paramValue = iter.next();
    preparedStatement.setObject(i, paramValue);
voidclose(PreparedStatement preparedStatement)
close
close(null, preparedStatement, null, null);
voidclose(PreparedStatement stat)
close
try {
    if (null != stat)
        stat.close();
} catch (SQLException e) {
    e.printStackTrace();
voidclosePreparedStatement(Map psMap)
close Prepared Statement
for (Iterator itr = psMap.values().iterator(); itr.hasNext();) {
    Object[] obj = (Object[]) itr.next();
    ((PreparedStatement) obj[1]).close();
voidclosePreparedStatement(PreparedStatement pstmt)
close Prepared Statement
if (pstmt != null) {
    try {
        pstmt.close();
    } catch (SQLException e) {
        e.printStackTrace();
    pstmt = null;
voidclosePreparedStatement(Statement ps)
close Prepared Statement
try {
    if (ps != null)
        ps.close();
} catch (SQLException e) {
    e.printStackTrace();
voidclosePS(PreparedStatement argPreparedStatement)
Closes the given prepared statement.
if (argPreparedStatement != null) {
    argPreparedStatement.close();
voidcloseSilentlyPreparedStatement(PreparedStatement stmt)
Closes a PreparedStatement silently (no exception raised).
try {
    stmt.close();
} catch (SQLException e) {
voidcloseStatement(PreparedStatement preparedStatement)
Method to close the PreparedStatement
if (preparedStatement != null) {
    try {
        preparedStatement.close();
    } catch (SQLException exception) {
        exception.printStackTrace();