K
kevinfu
Unregistered / Unconfirmed
GUEST, unregistred user!
在BEAN中有这样一函数,
public ResultSet executeQuery(String sql) {
try {
DriverManager.setLoginTimeout(10);
Connection connection = DriverManager.getConnection(url,login,password);
connection.setCatalog(ConDB);
Statement st = connection.createStatement();
rs = st.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("JDBCMSSQL.executeQuery: " + ex.getMessage());
}
return rs;
}
我在JSP文件中有个INSERT 语句。
&lt%
....
usql="insert into dbo.contactus(...) values(...)";
ResultSet RS = workM.executeQuery(usql);
RS.close();
%&gt
提交执行,有错信息在JAVA窗口,但数据库已增加资料。
我猜想,这于返回值有关,但我不知道,INSERT,DELETE,或SELETC getdate() 的返加值
请取什么,使用什么'字段',result[0]???, 谁能告诉我,有例子吗?
JAVA 窗口错误如下:
JDBCMSSQL.executeQuery: [TDS Driver]No result sets were produced by 'INSERT INTO
dbo.ContactUs(FirstName, LastName, Company, Street, Zip, City, State, Country,
Tel, Fax, WebSite, Email, Msg, InDate, Process, PrDate, DeleteIt)VALUES ('Lingli
ng','Yu','Ace Mold company limited','','','','','','','','','ling@ie','se
fw','','N','','N')'
Unhandled error! You might want to consider having an error page to report such
errors more gracefully
java.lang.NullPointerException
at webpages.Contact.ContPost_jsp_6._jspService(ContPost_jsp_6.java:120)
at com.sun.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
ava:88)
at com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:218)
at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155
)
at com.sun.web.core.Context.handleRequest(Context.java:414)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
java.io.IOException: Socket Closed
at java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:421)
at java.net.Socket$1.run(Socket.java:335)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.Socket.getInputStream(Socket.java:332)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)
public ResultSet executeQuery(String sql) {
try {
DriverManager.setLoginTimeout(10);
Connection connection = DriverManager.getConnection(url,login,password);
connection.setCatalog(ConDB);
Statement st = connection.createStatement();
rs = st.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("JDBCMSSQL.executeQuery: " + ex.getMessage());
}
return rs;
}
我在JSP文件中有个INSERT 语句。
&lt%
....
usql="insert into dbo.contactus(...) values(...)";
ResultSet RS = workM.executeQuery(usql);
RS.close();
%&gt
提交执行,有错信息在JAVA窗口,但数据库已增加资料。
我猜想,这于返回值有关,但我不知道,INSERT,DELETE,或SELETC getdate() 的返加值
请取什么,使用什么'字段',result[0]???, 谁能告诉我,有例子吗?
JAVA 窗口错误如下:
JDBCMSSQL.executeQuery: [TDS Driver]No result sets were produced by 'INSERT INTO
dbo.ContactUs(FirstName, LastName, Company, Street, Zip, City, State, Country,
Tel, Fax, WebSite, Email, Msg, InDate, Process, PrDate, DeleteIt)VALUES ('Lingli
ng','Yu','Ace Mold company limited','','','','','','','','','ling@ie','se
fw','','N','','N')'
Unhandled error! You might want to consider having an error page to report such
errors more gracefully
java.lang.NullPointerException
at webpages.Contact.ContPost_jsp_6._jspService(ContPost_jsp_6.java:120)
at com.sun.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
ava:88)
at com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:218)
at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155
)
at com.sun.web.core.Context.handleRequest(Context.java:414)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
java.io.IOException: Socket Closed
at java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:421)
at java.net.Socket$1.run(Socket.java:335)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.Socket.getInputStream(Socket.java:332)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)