PROBLEM with using multiple PreparedStatement object

Hello friends

i have following code in which m using Two Statement Object's

<%@ page import="java.sql.*,com.example.model.*" session="true" %>

<%!

ResultSet rs1,rs2;

Statement stmt1;

Statement stmt2;

Connection con;

%>

<%

dbcon cn=new dbcon();

con=cn.connectdb();

try

{

stmt1=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

stmt2=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

rs1=stmt1.executeQuery("select mf_id,mf_lr_id from Manifest where mf_manifestno=604");

if(rs1.next())

{

do

{

int mfid=rs1.getInt("mf_id");

int lrid=rs1.getInt("mf_lr_id");

out.println(mfid);

out.println(lrid);

String getLr="Select lr_no from Lr_Tran where lr_id="+lrid; //lrid getting from outer query

rs2=stmt2.executeQuery(getLr);

out.println(getLr+"<br>");

if(rs2.next())

{

do{

out.println("<br>"+"hello");

out.println(rs2.getInt("lr_no"));

}while(rs2.next());

}

}while(rs1.next());

}

}catch(SQLException se)

{

-

}

%>

so its running fine but i hav tow queries

1>m using

stmt1=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

stmt2=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

n its working fine

but its not working when m using

stmt1=con.createStatement();

stmt2=con.createStatement();

why i clould'nt wrok with these line

2>as my above code is runnig fine with two Statemenrt Object

but i wana run above code with two PreparedStatement object then how is posible

plz help me soon

[1871 byte] By [amol_0008@rediffmail.coma] at [2007-11-27 5:27:54]
# 1
1) Use a JOIN rather than two statements. See http://www.google.com/search?q=sql+tutorial+join2) Use of PreparedStatement is explained in http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
BalusCa at 2007-7-12 14:49:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
thanks for the reply but it was my dummy query in real scinario i need to use two statement object (m using that in Structured Report)(if i could use two PreparedStaement then it will very nice )So Will U plz tell me what code i shud use
amol_0008@rediffmail.coma at 2007-7-12 14:49:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Then just ignore my answer at 1) and read my answer at 2) and do it twice.
BalusCa at 2007-7-12 14:49:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...