27/03/05
Still cannot Execute the SQL comamnd
2005/3/27 上午 02:49:50 org.apache.coyote.http11.Http11Protocol init
資訊: Initializing Coyote HTTP/1.1 on http-8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.31
2005/3/27 上午 02:49:51 org.apache.struts.util.PropertyMessageResources
資訊: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
2005/3/27 上午 02:49:51 org.apache.struts.util.PropertyMessageResources
資訊: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
2005/3/27 上午 02:49:52 org.apache.struts.util.PropertyMessageResources
資訊: Initializing, config='org.apache.webapp.admin.ApplicationResources', retur
nNull=true
2005/3/27 上午 02:49:54 org.apache.coyote.http11.Http11Protocol start
資訊: Starting Coyote HTTP/1.1 on http-8080
2005/3/27 上午 02:49:54 org.apache.jk.common.ChannelSocket init
資訊: JK2: ajp13 listening on /0.0.0.0:8009
2005/3/27 上午 02:49:54 org.apache.jk.server.JkMain start
資訊: Jk running ID=0 time=0/31 config=C:\Tomcat 4.1\conf\jk2.properties
Step 4: Create a statement
step 5: execute a quer
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]No ResultSet s
et was produced.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown So
urce)
at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
at RegForm.inputRecord(RegForm.java:68)
at RegForm.doGet(RegForm.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:15
2)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Error when executing inputRecord!
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]No ResultSet set was produced.
I decide to update the hk dollar account in order to try to update the database
12.00
I realize the problem may not just related to the SQL command only, so i ask Shin.
12.30
After sending my problem to Shin, he sends me a copy of basic Servlet codes, just run it, compile it, little changes and re-compiled. Done.
Problem: still un-found, but may be related to the complicated commands that i have typed in. The command rs.close(); db.close(); and object.close(); etc are not added in Shin's coding.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter out = response.getWriter();
out.println("Hello World 2");
String result;
try
{
out.println("0");
String url = "jdbc:microsoft:sqlserver://w2ksa.cs.cityu.edu.hk:1433;databaseName=iad08_db;";
out.println("1");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
out.println("2");
String dbLoginId = "iad08"; // database login ID
String dbPwd = "iad08abc"; // database password?
out.println("3");
Connection con = DriverManager.getConnection(url, dbLoginId, dbPwd);
out.println("4");
Statement stmt = con.createStatement();
String strSQL = "SELECT * FROM UserInfo";
ResultSet rs = stmt.executeQuery(strSQL);
} catch(Exception expt)
{
out.println("fail !!!!");
out.println(expt);
}
}
}
13.45
I can modified my code and input the database, from the web-browser, to the database. But the auto-increment of that test table not suitable test the real cases.
14.25
Successful on updating the test table by ignoring the command connnection.close() and statement.close().
14:35
I think I should keep the connection.close() there.
After a tea-break, successes!
Remember to match the type, cf, char, varchar match string and int, tinyint match int, float,decimal match double, float
20.17
How to close the session.
21.07
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=1&threadID=3484&tstart=30
21.21
modify the HTML file – registration.html with JavaScript,
line 28 - > document.registerate
21.53
Exception handling under the ResultSet
Something added in line 135
//stmt.executeQuery(strSQL3);
//System.out.println("9.1");
rs = stmt.executeQuery(strSQL3);
System.out.println("9.1.1");
try{
strUid = rs.getString("u_id");
System.out.println(strUid);
}catch(SQLException sqlex){
System.out.println("Error in the SQLQuery");
throw sqlex;
}
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html