This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested resultsets with 1 connection, possible?

 
Sandy Goh
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have nested resultsets but I can only use 1 connection to the database.
Is it possible?
Thanks ppl!
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%
String url = "jdbc dbc:company";
Connection conn=null;
String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName(classPath);
conn = DriverManager.getConnection(url,username,password);
}catch(Exception exc){
out.println(exc.toString());
}
Statement stm=null;
Statement stm1=null;
stm1=conn.createStatement();
stm=conn.createStatement();
ResultSet rst=null;
ResultSet rst1=null;

try{
rst=stm.executeQuery("Select DISTINCT comagent from company");

%>

<% while(rst.next()){ %>

<%String agent=rst.getString("comagent");%>
<%rst1=stm1.executeQuery("Select * from company where comagent='"+agent+"' ORDER BY comlead DESC");
rst1.next();%>
<%=rst1.getString("comname")%>
<%=rst1.getString("comlead")%>
<%
}%>

<%
%>
<%}catch(Exception exc){
out.println(exc.toString());
}
stm1.close();
stm.close();
conn.close();

%>
 
Dana Hanna
Ranch Hand
Posts: 227
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but I've found problems with some databases...
 
Sandy Goh
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get what you mean?
 
Dana Hanna
Ranch Hand
Posts: 227
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This did not work for us when using DB2 UDB 6.1 fixpack 3. Upgrading to fixpack 9 fixed it.
I've never had any other problems though. You should be fine, and you are doing everything correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic