I m facing problem in this code. I m using WebLogic. Whenever i execute this
code, Server response with error Recordset is closed. what is happening i cannt
understand.
can u help me.
ResultSet ts = null;
String excode="";
String seg="";
String Company="";
Statement st = null;
Statement st1 = null;
Connection con = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
con = DriverManager.getConnection("jdbc:odbc:backoffice","sa","du");
st = con.createStatement();
st1 = con.createStatement();
if (UserCode.equals("NSE6378")) Company="Bonanza Portfolio Ltd";
else if (UserCode.equals("BSE235")) Company="Bonanza Stock Brokers Ltd";
else Company="Bonanza Group";
out.println("<h3 align=center>"+Company.toUpperCase()+"</h3>");
SQL="select count(*) Knt from backoffice..tblSettlements where
Segment<>'Derivative' and SettlementNo='" + SettlementNo + "'";
ts=st.executeQuery(SQL);
if(ts!=null)
{
while(ts.next())
{
int knt = ts.getInt("Knt");
if (knt==0 ){
out.println("<h5>No Such Settlement Found for Cash Segment!!</h5>");
return;
}
}
}
ts.close();
SQL="exec backoffice..getM2mccf '"+ UserCode +"' ,'"+ Login +"' ,'"+
SettlementNo +"','" + Types +"','" + Code + "','" + NDScrip +"'";
out.println("<h5>Mark to Market for Settlement No- " +
SettlementNo.toUpperCase() + "</h5>");
ts=st.executeQuery(SQL);
int DATA_FOUND=0;
if(ts!=null){
out.println("<Table border=1 cellspacing=0 cellpading=0>");
while(ts.next())
{
CurrClientCode=ts.getString("ClientCode");
Name=ts.getString("FullName");
String SaleQty=ts.getString("SaleQty");
double SaleValue=ts.getDouble("SaleValue");
String BuyQty=ts.getString("BuyQty");
double BuyValue=ts.getDouble("BuyValue");
String NetQty=ts.getString("NetQty");
double NetValue=ts.getDouble("NetValue");
String ActualClosingValue=ts.getString("ActualClosingValue");
String AvgRate=ts.getString("AvgRate");
Scrip=ts.getString("ScripName");
String ActualClosingRate=ts.getString("ActualClosingRate");
String NetDiff=ts.getString("NetDiff");
if (PrevClientCode.equals(""))
{
%><tr><th BGCOLOR=lightBlue colspan=11><%
out.println(CurrClientCode+" - "+Name+HEADER);
Code=CurrClientCode;
}
else
{
if (PrevClientCode.equals(CurrClientCode) ){
file://Code=" ";
file://Name=" ";
file://Code=PrevClientCode;
}else{
Code=CurrClientCode;
%><tr><td colspan=11> </td></tr><tr><th BGCOLOR=lightBlue
colspan=11><%
out.println(CurrClientCode+" - "+Name+HEADER);
}
}
if (Scrip.equals("ZZZZZZZZZZZZZZZ"))
{
out.print("<BR>InScript...<BR>");
/*author : Umashankar Yadav
Date : 23rd April 2004
Purpose : in order to include the charge amount in buy value and
subtracting that from sale value a net value will be displayed
only when the total is showing for the particular client this will be
included
*/
ResultSet rst=null;
double tot=0.0;
file://SQL="exec backoffice..getChargeAmount '"+ SettlementNo +"' ,'"+
CurrClientCode +"'";
file://SQL="exec backoffice..getClientCharge '"+ UserCode +"' ,'"+
SettlementNo +"' ,'"+ Code +"'";
SQL="exec backoffice..getClientCharge '"+ UserCode +"' ,'"+ SettlementNo +"'
,'"+ CurrClientCode +"'";
rst=st1.executeQuery(SQL);
if(rst!=null)
{
rst.next();
tot = rst.getDouble(1);
}
rst.close();
file://tot=2.5;
double bv = BuyValue;
double nv = NetValue;
BuyValue = BuyValue + tot;
NetValue = SaleValue-BuyValue;
if(NetValue<0)
{
out.println("<tr bgcolor=silver><td colspan=3
align=right>"+myFormatt.format(bv)+"</td><td colspan=2
align=right>"+myFormatt.format(SaleValue)+"</td><td colspan=2
align=right>"+myFormatt.format(nv)+"</td><td colspan=3
align=right>"+NetDiff+"</td></tr><tr><td colspan= 5 border=0>Total
Charges Exclusive of Brokerage: " +myFormatt.format(tot)+"</td><td
colspan = 5 border = 0>Bill Amount <font color=red> " +
myFormatt.format(NetValue) + " Dr</font></td></tr>");
}
else
{
out.println("<tr bgcolor=silver><td colspan=3
align=right>"+myFormatt.format(bv)+"</td><td colspan=2
align=right>"+myFormatt.format(SaleValue)+"</td><td colspan=2
align=right>"+myFormatt.format(nv)+"</td><td colspan=3
align=right>"+NetDiff+"</td></tr><tr><td colspan = 5 border=0>Total
Charges Exclusive of Brokerage: " +myFormatt.format(tot)+"</td><td
colspan = 5 border = 0>Bill Amount <font color=blue> " +
myFormatt.format(NetValue) + " Cr</font></td></tr>");
}
}
else
{
out.print("<BR>OutScrip...<BR>");
out.println("<tr><td nowrap>"+Scrip+"</td><td align=right>"+BuyQty+"</td><td
align=right>"+BuyValue+"</td><td align=right>"+SaleQty+"</td><td
align=right>"+SaleValue+"</td><td align=right>"+NetQty+"</td><td
align=right>"+NetValue+"</td><td align=right>"+AvgRate+"</td><td
align=right>"+ActualClosingRate+"</td><td align=right>"+NetDiff+"</td></tr>");
}
PrevClientCode=CurrClientCode;
DATA_FOUND=1;
}
file://end of while loop
out.println("</tbody></table>");
}
if (DATA_FOUND==0)
out.println("No Trades for this Settlement<br>");
}
catch(SQLException e){
out.println("Error:-"+e.getMessage());
}catch(Exception e){
out.println("Error:-"+e.getMessage());
}
if (con!=null) con.close();
%>