java代码:
public int editportal(String env,String region,String url,String user,String rnode,String password,int envid,String attuid) throws Exception
{
int Affected=0;
log.debug("[Editconsole Method Call]");
try {
Connection con = db.getConnection();
String editquery = "update ENV_MOTS_DETAILS set " +
"ENV_NAME= ? , CONSOLE_URL= ? , REMOTE_NODE= ? , CONSOLE_TO_LOGON=? , " +
"REGION=? , DELETE_FLAG='Y' , ADMIN_PWD=? , " +
"COMPONENT='' , COMMENTS='' , LAST_UPDATED_BY=?, " +
"LAST_UPDATED_ON=to_date(to_char(SYSDATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS') WHERE ENV_ID = ?";
log.info("[Editconsole Method Call Query]"+editquery);
PreparedStatement ps1 = con.prepareStatement(editquery);
ps1.setString(1,env);
ps1.setString(2,url);
ps1.setString(3,rnode);
ps1.setString(4,user);
ps1.setString(5,region);
ps1.setString(6,password);
ps1.setString(7,attuid);
ps1.setInt(8,envid);
Affected = ps1.executeUpdate();
log.info("Statement affected " + Affected + " rows");
ps1.close();
con.close();
}
catch (Exception e)
{
log.fatal("[SQL Exception in Edit Server Details]"+e.getMessage());
throw e;
}
return Affected;
}
当我故意尝试获取错误或返回值为0时的堆栈跟踪
java.sql.SQLException:ORA-12899:值太大而不能列#34; INFRAJEWL"。" ENV_MOTS_DETAILS"。" ADMIN_PWD" (实际:147,最大值:50)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at com.amdocs.infraportal.query.GetServerInfoDao.editportal(GetServerInfoDao.java:202)
at com.amdocs.infraportal.servlets.Edit.doPost(Edit.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
答案 0 :(得分:3)
查看executeUpdate()的文档。它的返回值不应用于确定更新是否成功。
答案 1 :(得分:-1)
executeUpdate()
的{{1}}方法始终返回