CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2597|Reply: 2

help me on JSP..

[Copy link]
Post time 15-4-2009 11:38 AM | Show all posts |Read mode
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
   
  }
Reply

Use magic Report


ADVERTISEMENT


Post time 17-4-2009 03:24 AM | Show all posts

Reply #1 saeah85's post

Nape ek nk pakai sampai 18 connection pool ?? based on coding ni...process run dlm loop...maknanye sume nye sequential...so initialize skali je connection patut da cukup...unless tiap2 kali process dlm loop tu nk connect to different database or schema...

Try tgk page ni utk guide http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html

*p/s: Tuan rumah pakai webserver ape ek ?
Reply

Use magic Report

 Author| Post time 19-4-2009 11:04 PM | Show all posts
Originally posted by digitalgunner at 17-4-2009 03:24
Nape ek nk pakai sampai 18 connection pool ?? based on coding ni...process run dlm loop...maknanye sume nye sequential...so initialize skali je connection patut da cukup...unless tiap2 kali proce ...


ekceli coding ni org len yg develop..then aku kna sambung..
yg bleh jadi 18 connection tu sbb setiap kali loop dia akan connect ngan database yg berbeza base on the server address yg dah diset kan..sbb loop ni proses nak sum kan data dari 18 tempat yg berbeza..setiap tempat tu ade satu database masing2..aku ni baru beginner ngan jsp nih..tu yg sedikit blur tu bile dpt coding yg advance mcm nih..

aku gune apache tomcat..nape?btw, thanx for replying yaaa
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

10-1-2025 05:25 AM GMT+8 , Processed in 0.066762 second(s), 16 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list