1
public void saveNewParam(Connection conn, GlobalParamDTO globalParamDTO) throws SLCMException {
SLCMLog.info("Enter saveNewParam()");
PreparedStatement pstmt = null;
String query = SLCMQueryConstant.INSERT_GLOBAL_PARAM;
try {
int count = 1;
pstmt = conn.prepareStatement(query);
pstmt.setInt (count++, globalParamDTO.getParamTypeID());
pstmt.setString(count++, globalParamDTO.getParamValue());
pstmt.setString(count++, globalParamDTO.getParamValueHindi());
System.out.println(globalParamDTO.getParamValueHindi());
pstmt.executeUpdate();
} catch (Exception e) {
throw new SLCMException(e.getMessage());
} finally {
ConnectionManager.close(null, null, null, pstmt);
}
}
無異常或錯誤的表 查詢 -無異常或錯誤仍然沒有在表中插入值
public static final String INSERT_GLOBAL_PARAM = new StringBuilder("").
append(" INSERT INTO m_global_param (Param_Type_ID,Value,Value_Hindi) ").
append(" VALUES(?,?,?)").toString();
檢查自動提交是否爲連接錯誤。 – 11thdimension
此表的自動增量值爲True。並且Param_ID列可以自動增加。 – Nidhi
在JDBC自動提交中自動提交。您可以通過在代碼中插入後立即運行select查詢來驗證數據是否被插入,如果您在select查詢中獲取數據,那麼它只能表示您的連接的自動提交是false,並且您必須手動提交通過在最後調用'connection.commit()'進行連接。 – 11thdimension