问题
I have Created an Java Swing Application with MySQL as the database, Now i am hosting my MySQL database online and Swing Application will be stored locally, Now in order to experiment i have hosted my database i.e MySQL database on https://www.freemysqlhosting.net/ account as it allows free hosting for certain period, Also Connection is successfull and works but the application works too slow suppose if i have to search any entry from the swing aplication from the oline hosted database it works too slow,it is happening like i have to press any key or button and has to wait for the processing of the transaction. Does connection pooling technique will solve the performance issues, If yes which is best one and if not what can i do to solve this. Please Help
Below is the code which i have written to make database transactions and i am doing this everytime i make a database access
public ArrayList<ChargeSheet> readByAllCompanyInfo(String cityname)
{
ArrayList<ChargeSheet> list = new ArrayList<ChargeSheet>();
con=db.getConnection();
try{
pst = con.prepareStatement("select * from tblcompanyinformation where companyname = ?");
pst.setString(1,cityname);
rs = pst.executeQuery();
while(rs.next()){
ChargeSheet clientInformation=new ChargeSheet();
clientInformation.setRecieptno(rs.getInt(2));
clientInformation.setPresentdate(rs.getString(3));
clientInformation.setCompanyname(rs.getString(4));
clientInformation.setPhone(rs.getString(5));
list.add(clientInformation);
}
}
catch(SQLException ex){
setLastError(ex.getMessage());
}
finally{
db.closeConnection();
}
return list;
}
回答1:
With that code, it is likely that using a connection pool will improve performance. Especially if you are using SSL-enabled connections.
(Of course, this assumes that you use the same pool for connecting.)
If yes which is best one ....
Recommendations are Off-Topic for StackOverflow, but I'm sure you could find a website that lists and compares some popular alternatives.
来源:https://stackoverflow.com/questions/40358852/does-connection-pooling-makes-java-swing-application-works-faster-for-remote-mys