JDBC code which passes one input and fetches the other values from database table.
Connection objConnection=null;
PreparedStatement objPreparedStmt = null;
ResultSet objResultSet = null;
try {
objConnection = DBUtility.getConnection();
objPreparedStmt = objConnection.prepareStatement(SELECT PARAMETERCODE, PARAMETERVALUE, SYSTEMSTATUSKEY FROM OWN_GTEM.CONTROLPARAMETERS WHERE PARAMETERCODE=?);
objPreparedStmt.setString(1, objUserDTO.getOpeningRemarksCode());
objResultSet = objPreparedStmt.executeQuery();
while (objResultSet.next()) {
openingRemarksCode = objResultSet.getString("PARAMETERCODE");
openingRemarksValue = objResultSet.getString("PARAMETERVALUE");
openingRemarksStatus = objResultSet.getString("SYSTEMSTATUSKEY");
}
DBUtility.closeResultSet(objResultSet);
objPreparedStmt.executeUpdate();
objConnection.commit();
} catch (Exception ex) {
ABCLogger. ABCLog(CLASS_NAME,
"In updateOpeningRemarks()->SQLException:" + ex.getMessage(),ABCLogger.ERROR);
ex.printStackTrace();
} finally {
DBUtility.closeStatement(objPreparedStmt);
DBUtility.closeResultSet(objResultSet);
DBUtility.releaseConnection(objConnection);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment