很简单啊,用对象前判断是否为空就可以啦if (rs != NULL) {
if (rs.getInt("result") == 0) {
result = "无法定位记录,记录更新前已被更改.";
}
}
if (rs.getInt("result") == 0) {
result = "无法定位记录,记录更新前已被更改.";
}
}
解决方案 »
- 急求大虾指点。struts1与jquery的整合问题
- hibernate开发流程
- MyEclipse代码编辑器的问题。
- 多表声明式事务配置
- 请教各位大虾问题,关于邮箱/即时通讯工具联系人的导入
- QQ群:1883748,专门探讨struts等框架开发。高手就进!
- using session bean
- cyclic inheritance involving是怎么回事?谢谢!
- JBUILDER8和JBOSS3.04(与TOMCAT4.1合成)能够实现WEB SERVICE功能的开发吗?
- springmvc整合shiro报错
- 纯JAVA中这样去连接数据库
- myEclipse开发struts小问题,谢谢
<2007-8-16 上午10时21分32秒> <Notice> <WebLogicServer> <000360> <Server started
in RUNNING mode>
java.lang.Exception: java.lang.ClassCastException
at com.ParseXML.getConnection(Unknown Source)
at com.ParseXML.createSQLStatement(Unknown Source)
at promilestone.MsAppServerBean.updateBatch(MsAppServerBean.java:69)
at promilestone.MsAppServerBean_nt0n1a_EOImpl.updateBatch(MsAppServerBea
n_nt0n1a_EOImpl.java:3426)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.j
ava:372)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider
.java:292)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:
276)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437
)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:70
1)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBas
e.java:335)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:945)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:332)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:242)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5363)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:721)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3043)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2466)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
Caused by: java.lang.ClassCastException
... 29 more
java.lang.NullPointerException
at promilestone.MsAppServerBean.updateBatch(MsAppServerBean.java:90)
at promilestone.MsAppServerBean_nt0n1a_EOImpl.updateBatch(MsAppServerBea
n_nt0n1a_EOImpl.java:3426)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.j
ava:372)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider
.java:292)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:
276)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437
)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:70
1)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBas
e.java:335)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:945)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:332)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:242)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5363)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:721)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3043)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2466)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
public class ConnectServer {
public static String mainDataSoure = "MsTxDSSQLServer"; public ConnectServer() {
} public java.sql.Connection getConnection() {
InitialContext initCtx = null;
try {
initCtx = new InitialContext();
DataSource ds = (javax.sql.DataSource) initCtx.lookup(mainDataSoure);
return ds.getConnection();
}
catch (Exception ne) {
throw new EJBException(ne);
}
finally {
try {
if (initCtx != null) {
initCtx.close();
}
}
catch (NamingException ne) {
throw new EJBException(ne);
}
}
} public java.sql.Connection getConnection(String dataSource) {
String txdataSource = dataSource;
if (txdataSource.equals("")) {
txdataSource = mainDataSoure;
}
InitialContext initCtx = null;
try {
initCtx = new InitialContext();
DataSource ds = (javax.sql.DataSource) initCtx.lookup(txdataSource);
return ds.getConnection();
}
catch (Exception ne) {
throw new EJBException(ne);
}
finally {
try {
if (initCtx != null) {
initCtx.close();
}
}
catch (NamingException ne) {
throw new EJBException(ne);
}
}
} public java.sql.Connection getConnection(int dataSource) {
java.sql.Connection con = getConnection(); InitialContext initCtx = null;
try {
initCtx = new InitialContext();
DataSource ds = (javax.sql.DataSource) initCtx.lookup(mainDataSoure);
return ds.getConnection();
}
catch (Exception ne) {
throw new EJBException(ne);
}
finally {
try {
if (initCtx != null) {
initCtx.close();
}
}
catch (NamingException ne) {
throw new EJBException(ne);
}
}
} public void cleanup(Connection con, PreparedStatement ps) {
try {
if (ps != null) {
ps.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
//将数据库联接返回缓冲池
try {
if (con != null) {
con.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
}