This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with resultset in reference with my previous post

 
lusha tak
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 /> %>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic