|
salam n morning semuanya!!!
aku nak mintak tlg ni daripada taiko2 programmer JSP sekalian..
dalam code kat bwh ni, ade connetionPool dalam gelung..gelung ni akan bergelung sebyk 18 kali..so, bile aku run kan kod nih, server xleh handle sbb ade byk connetion..jadi, aku punya idea aku perlu close kan connetionPool tu sblm gelung end..
so, kalu utk coonetionPool nih, method utk close connection dier sama mcm close connection biasa ker? or ade solution lain sbnrnye??
=========================================================================
for(int num=0;num<cuba.size();num++)
{
Statement svr =con.createStatement();
String ku="select * from server_list "+fcode+"";
ResultSet sets =svr.executeQuery(ku);
if(sets!=null)
sets.next();
svrname = sets.getString("foldername");
username = sets.getString("username");
password = sets.getString("password");
String driver1 ="com.mysql.jdbc.Driver";
url ="jdbc:mysql://localhost/ipamis_dbhq";
ConnectionPool constaf =new ConnectionPool(driver1,url,username,"xxxxxx",10,50,true);
con = constaf.getConnection();
//Statement stmcons = cons.createStatement();
double tval1=0;
Statement stmentinfo = cons.createStatement ();
ResultSet sett = stmentinfo.executeQuery("select t3.code,t3.descp,t3.type from enterprise_info as t3 where length(t3.code)>0 "+ enterprisetype2 +" "+ enterprise2 +" order by t3.code");
while(sett.next())
{
for (int a=1;a<=Integer.parseInt(period);a++)
{
if(sett.getString("descp").equalsIgnoreCase("Oil Palm"))
{
oil_exrate+=getEntOilPercentThisMonth(year,String.valueOf(a),"01",fcode,cuba);
oil_exrate_budget+=getEntOilPercentThisMonthBudget(year,String.valueOf(a),"01",fcode,cuba);
}//end of oilpalm
}
}//end of num
} |
|