•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 426,514 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,105 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 480 | Replies: 2
![]() |
•
•
Join Date: Feb 2008
Posts: 36
Reputation:
Rep Power: 1
Solved Threads: 1
iam getting problem while using resultset within resultset like...
java Syntax (Toggle Plain Text)
while(rs.next()){ ....... ...... s=rs.getString(1); while(rs1.next()){ ------ ------- } //after completion of inner result set iam not getting values of outer resultset (null) like rs.getString(1);//nullpointer exception if i store in variable like in s above show then getting eventhough getting likethat but iam not getting next record mean not calling rs.next() }//rs.next()
Last edited by peter_budo : Jul 23rd, 2008 at 12:50 pm. Reason: Keep It Organized - please use [code] tags
Use a new statement object to retreive the second resultset, as, as the API docs clearly state, executing another SQL command on a statement object will automatically close all previously opened resultsets associated with that statement.
Last edited by masijade : Jul 23rd, 2008 at 12:38 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 0
Solved Threads: 0
query="select * from login where username='"+username+"'and usertype="+usertype+"";
ps=con.prepareStatement(query);
rs=ps.executeQuery();
while (rs.next())
{
if (rs.getString("password").equals(password))
{
session.setAttribute("userid", rs.getString("userid"));
session.setAttribute("usertype", rs.getString("usertype"));
session.setAttribute("loginstatus", "1");
if(rs.getString("userid").equals("0"))
{
%>
<jsp:forward page="adminhome.jsp"></jsp:forward>
<%
}
if(rs.getString("usertype").equals("2"))
{
String query1="select designation from emp_work_profile where userid="+session.getAttribute("userid")+"";
ResultSet rs1=null;
PreparedStatement ps1=null;
ps1=con.prepareStatement(query1);
rs1=ps1.executeQuery();
while(rs1.next())
{
if(rs1.getString("designation").equals("6")||rs1.getString("designation").equals("7"))
{
}This works correctly for me i am using two different result set.
For more codesnippets please visit
<URL SNIPPED>
Last edited by peter_budo : Jul 23rd, 2008 at 3:00 pm. Reason: Keep It Spam-Free - Do not spam, advertise, plug your website, or engage in any other type of self promotion.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- insert values to mysql database (JSP)
- Type mismatch: cannot convert from int to ResultSet (JSP)
- ResultSet.... getterMethod() (Java)
- resultset updatable (Oracle)
- How in PHP get ResultSet of PostGreSql-function? (PHP)
- Randomizing Database Questions (Java)
- how do i display updated records from database (Java)
- Java JDBC ResultSet (Java)
Other Threads in the JSP Forum
- Previous Thread: Connection to database
- Next Thread: How to retrive data two times from database in single jsp page.



Linear Mode