prepStmt = dbConnection.prepareStatement(sqlStmt);
if (params != null && params.length > 0) {
for (int i = 0; i < params.length; i++) {
Object param = params[i];
if (param == null) {
throw new UserStoreException("Invalid data provided");
} else if (param instanceof String) {
prepStmt.setString(i + 1, (String) param);
} else if (param instanceof Integer) {
prepStmt.setInt(i + 1, (Integer) param);
} else if (param instanceof Date) {
//Timestamp timestamp = new Timestamp(((Date) param).getTime());
//prepStmt.setTimestamp(i + 1, timestamp);
prepStmt.setTimestamp(i + 1,new Timestamp(System.currentTimeMillis()));
} else if (param instanceof Boolean) {
prepStmt.setBoolean(i + 1, (Boolean) param);
}
}
}
int count = prepStmt.executeUpdate();
if(count == 0) {
log.info("No rows were updated");
}
if (log.isDebugEnabled()) {
log.debug("Executed querry is " + sqlStmt + " and number of updated rows :: "
+ count);
}
if (localConnection) {
dbConnection.commit();
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
log.error("Using sql : " + sqlStmt);
throw new UserStoreException(e.getMessage(), e);
} finally {
if (localConnection) {
DatabaseUtil.closeAllConnections(dbConnection);
}
DatabaseUtil.closeAllConnections(null, prepStmt);