• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

error while using two resultset object in jsp page.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<%
String a=request.getParameter("msg");
String s="";
String str1="";

Connection con=null;
Statement smt=null;
Statement smt1=null;
ResultSet rs1=null;
ResultSet rs2=null;

try
{


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:MyNewProjectDsn");
smt= con.createStatement();
//smt1= con.createStatement();
rs1= smt.executeQuery("select * from empregtbl where e_login='"+a+"'");

while(rs1.next())
{
str1= rs1.getString(21);


rs2= smt.executeQuery("select * from compadd where Reg_id='"+str1+"'");

if(rs2.next())
{%>

<center><b><font size="5">
<table cellspacing="10">

<tr>
<td align="left" bgcolor="gray"> Registraion Id     </td><td align="right" bgcolor="pink"><%=rs2.getString(1)%></td>

</tr>


<tr>
<td align="left" bgcolor="gray"> First Name     </td><td align="right" bgcolor="pink"><%=rs2.getString(2)%></td>

</tr>


<tr>
<td align="left" bgcolor="gray">Last Name     </td><td align="right" bgcolor="pink"><%=rs2.getString(3)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">DOB     </td><td align="right" bgcolor="pink"><%=rs2.getString(4)%>/<%=rs2.getString(5)%>/<%=rs2.getString(6)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Pan Card No     </td><td align="right" bgcolor="pink"><%=rs2.getString(7)%></td>

</tr>



<tr>
<td align="left" bgcolor="gray">Qualification     </td>
<td align="right" bgcolor="pink">
<%=rs2.getString(8)%>
</td>

</tr>



<tr>
<td align="left" bgcolor="gray">Year Of Completion     </td><td align="right" bgcolor="pink"><%=rs2.getString(9)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Experience     </td><td align="right" bgcolor="pink"><%=rs2.getString(10)%> Yr</td>
</tr>

<tr>
<td align="left" bgcolor="gray">Current Company Name     </td><td align="right" bgcolor="pink"><%=rs2.getString(11)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Previous Company Name     </td><td align="right" bgcolor="pink" ><%=rs2.getString(12)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Current Position     </td><td align="right" bgcolor="pink"><%=rs2.getString(13)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Signed Bond Of     </td><td align="right" bgcolor="pink"><%=rs2.getString(14)%> Yr</td>

</tr>

<tr>
<td align="left" bgcolor="gray">Current Package     </td><td align="right" bgcolor="pink"><%=rs2.getString(15)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">DOJ     </td><td align="right" bgcolor="pink"><%=rs2.getString(16)%>/<%=rs2.getString(17)%>/<%=rs2.getString(18)%></td>

</tr>



<tr>
<td align="left" bgcolor="gray">Phone No     </td><td align="right" bgcolor="pink"><%=rs2.getString(19)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Email Id     </td><td align="right" bgcolor="pink"><%=rs2.getString(20)%></td>

</tr>


<tr>
<td align="left" bgcolor="gray">Address     </td><td align="right" bgcolor="pink"><%=rs2.getString(21)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Pin Code     </td><td align="right" bgcolor="pink"><%=rs2.getString(22)%></td>

</tr>



<tr>
<td align="left" bgcolor="gray">City     </td><td align="right" bgcolor="pink"> <%=rs2.getString(23)%> </td>



</tr>

<tr>
<td align="left" bgcolor="gray">State     </td><td align="right" bgcolor="pink"><%=rs2.getString(24)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Country     </td><td align="right" bgcolor="pink"><%=rs2.getString(25)%></td>

</tr>

</table>
</font>
</b>
</center>


<% }

else
{%>

<center><b><font size="5">
<table cellspacing="10">




<tr>
<td align="left" bgcolor="gray"> First Name     </td><td align="right" bgcolor="pink"><%=rs1.getString(1)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Middle Name:     </td><td align="right" bgcolor="pink"><%=rs1.getString(2)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Last Name     </td><td align="right" bgcolor="pink"><%=rs1.getString(3)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">DOB     </td><td align="right" bgcolor="pink"><%=rs1.getString(4)%>/<%=rs1.getString(5)%>/<%=rs1.getString(6)%></td>

</tr>


<tr>
<td align="left" bgcolor="gray">Gender:     </td><td align="right" bgcolor="pink"><%=rs1.getString(7)%></td>
</tr>

<tr>
<td align="left" bgcolor="gray">Pan Card No     </td><td align="right" bgcolor="pink"><%=rs1.getString(8)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Qualification:     </td><td align="right" bgcolor="pink"><%=rs1.getString(11)%></td>
</tr>

<tr>
<td align="left" bgcolor="gray">Percetage:     </td><td align="right" bgcolor="pink"><%=rs1.getString(12)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Year Of Completion:     </td><td align="right" bgcolor="pink"><%=rs1.getString(13)%></td>
</tr>

<tr>
<td align="left" bgcolor="gray">Experience     </td><td align="right" bgcolor="pink"><%=rs1.getString(14)%> Yr</td>
</tr>

<tr>
<td align="left" bgcolor="gray">Phone No     </td><td align="right" bgcolor="pink"><%=rs1.getString(15)%></td>

</tr>




<tr>
<td align="left" bgcolor="gray">Address     </td><td align="right" bgcolor="pink"><%=rs1.getString(16)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Pin Code     </td><td align="right" bgcolor="pink"><%=rs1.getString(17)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">City     </td><td align="right" bgcolor="pink"> <%=rs1.getString(18)%> </td>



</tr>

<tr>
<td align="left" bgcolor="gray">State     </td><td align="right" bgcolor="pink"><%=rs1.getString(19)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Country     </td><td align="right" bgcolor="pink"><%=rs1.getString(20)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray"> Registraion Id     </td><td align="right" bgcolor="pink"><%=rs1.getString(21)%></td>

</tr>

<tr>
<td align="left" bgcolor="gray">Email Id:     </td><td align="right" bgcolor="pink"><%=rs1.getString(22)%></td>

</tr>




</table>
</font>
</b>
</center>

<% }
}
}

catch (Exception exc) {
out.println(exc);
exc.getMessage();
}


finally
{
con.close();
smt.close();


}
%>


</body>
</html>







error-------

java.sql.SQLException: ResultSet is closed
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Step 1: Refactor so that all the Java code is in a model class. JSPs should not be doing any Java code, and certainly not DB access code.
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic