File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes problem with resultset in reference with my previous post Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem with resultset in reference with my previous post" Watch "problem with resultset in reference with my previous post" New topic
Author

problem with resultset in reference with my previous post

lusha tak
Ranch Hand

Joined: Dec 30, 2000
Posts: 185
Hi All!!
Thanks for ur concern in solving out my query.
as u asked for the code, i don't know how best i can represent it to u, as it's very easy easy to get confused with the project specific intricacies & database details.
one or two three things i would like to tell u
1. i don't what do u mean by thread safe sevlet or jsp page for that metter (and i only know that web server takes care of it by itself.)
2. i haven't closed my resultset object anywhere in the whole file as if i go about doing that then tomcat causes even more problem.
i mean i haven't used the folowing code anywhere in the file
resultset1.close();
resultset2.close();
statement1.close();
statement1.close();
conn.close();
now here is my code sample............................
ur help is very much required....
Thanks in advance
lusha

<%response.setContentType("text/html");<br /> response.setDateHeader("Expires",0);<br /> response.setHeader("Cache-Control","no-cache");<br /> response.setHeader("Pragma","no-cache");<br /> %>

<%@ page language='java' import='java.sql.*,javax.servlet.*,javax.servlet.http.*,java.io.*,java.sql.*,java.util.*' %><br /> <HTML><br /> <HEAD><br /> </HEAD><br /> <%<br /> HttpSession mysession=request.getSession(true);<br /> String user_type= (String)mysession.getValue("ut");<br /> //the following code checks for the vaidity of session<br /> if(mysession.isNew()| |(user_type==null))<br /> {<br /> //if invalid print "u have already logged out" on the terminal<br /> %><br /> <body bgcolor="#CCCC99" text="#333300" topmargin="0" leftmargin="0" marginheight=0 marginwidth=0 link="#FFFFFF" vlink="#FFFFFF"><br /> <br /> <br /> <center><h4>You have already logged out !</h4></center><br /> </body><br /> </html><br /> <%<br /> mysession.invalidate();<br /> }<br /> else<br /> {<br /> //if valid session do the folowing procesing<br /> %><br /> <body bgcolor="#CCCC99" text="#333300" topmargin="0" leftmargin="0" marginheight=0 marginwidth=0 link="#FFFFFF" vlink="#FFFFFF"><br /> <FORM name="frm" METHOD=POST ACTION="/ExamEngine/eval_paper.jsp"><br /> <%! <br /> //database objects declarations<br /> Connection conn=null;<br /> ResultSet resultset1=null;<br /> ResultSet resultset2=null;<br /> Statement statement1=null;<br /> Statement statement2=null;<br /> //other instance variable declarations such as<br /> String exam_cand_id;<br /> %><br /> <%<br /> //get value from session variable such as<br /> exam_cand_id = (String)mysession.getValue("exam_cand_id");<br /> %><br /> <br /> <%<br /> //database connection code<br /> <br /> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");<br /> conn=DriverManager.getConnection("jdbc dbc:ex_eng", "sa", "");<br /> statement1=conn.createStatement();<br /> statement2=conn.createStatement();<br /> <br /> //here some update statemnet with statement object "statement1"<br /> //here some select query statemnt with "statement1","resultset1"<br /> //retreiving values from "resultset1"<br /> //here some update statemnet with statement object "statement1"<br /> //here some select query statemnt with "statement1","resultset1"<br /> //retreiving values from "resultset1"<br /> //here some select query statemnt with "statement2","resultset2"<br /> //value retrieval from "resultset2"<br /> <br /> <br /> %><br /> <%<br /> }//end of else<br /> %>
 
 
subject: problem with resultset in reference with my previous post
 
Similar Threads
thread safety issue.......
problem with resultset in reference with my previous post
No margins in Netscape?
problem with result set,if multiple users access the application
frames