What is the problem in my Connection Pool ???
Hello,guys:
My using connection pool is in trouble,it always dies and does't output any error messages(can not get an available connection),so I should restart my Tomcat(4.1),
The following code in Login.jsp page initializes the pool :
<%
ConnectionPool cp = ConnectionPool.getInstance();
try{
if(cp.pool == null){
cp.initialize(50,5000);
System.out.println("Pool hava been initilized");
catch(Exception e){
System.out.println("ERROR:"+e);
%>and,call the following code in other JSPs and Servlets to use a connection got from the pool
ConenctionPool cp = ConnectionPool.getInstance(); // get an instance of ConnectionPool
Connection con = cp.getConnection(); //get a connection
Statement stmt = con.createStatement();
stmt.close();
cp.releaseConnection(con); //release the connection and push to the pool-----start of ConnectionPool.java----------
package mrp.util;
import java.util.Stack;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.util.Enumeration;
public final class ConnectionPool {
public Stack pool;
private long timeout;
private static ConnectionPool mySelf;
private Connection con;
private ConnectionPool() {
public static ConnectionPool getInstance(){
if(mySelf == null){
mySelf = new ConnectionPool();
return mySelf;
public synchronized void initialize(int numCons,long timeout) throws SQLException{
if(pool != null){
throw new SQLException ("Pool already initialized");
try{
this.timeout = timeout;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
pool = new Stack();
for(int i=0 ; i < numCons;i++){
pool.push(DriverManager.getConnection("jdbc:odbc:MRPII","sa","112233"));
catch(ClassNotFoundException ex){
throw new SQLException("Driver not found!!!");
public synchronized Connection getConnection() throws SQLException{
if(pool == null){
throw new SQLException ("Pool not initialized");
while(pool.empty()){
try{
wait(timeout);
catch(InterruptedException ex){
throw new SQLException ("Connection not available");
con = (Connection) pool.pop();
return con;
public synchronized void releaseConnection(Connection con) throws SQLException {
if(pool == null){
throw new SQLException ("Pool not initialized");
pool.push(con);
notifyAll();
public synchronized int getConnectionCount() throws Exception{
return pool.size();
public void destroyPool() throws SQLException {
if(pool == null){
throw new SQLException("Pool not initialized");
while(!pool.empty()){
((Connection)pool.pop()).close();
pool = null;
}-----End of ConnectionPool.java----------
Any suggestions? Thanks
a) call notifyAll after you finish initialize
instad you may wish to use your own releaseConnection per connection. so getConnection will work after one connection...
b)
for(int i=0 ; i < numCons;i++){
releaseConnection(DriverManager.getConnection("jdbc:odbc:MRPII","sa","112233"));
c) use an single instance rather than a static myPool. it will avoid confusion between the static and instance lock.
d) use a private constructor
d) call the initialize from getInstance() for sake. too much client code.
Similar Messages
-
i connect my iphone to my pc and i tunes open automatically,then i press dowload and update but itunes say am not connected to the internet while my pc is connected to the internet what isi the problem?
If you are the only user on your computer you probably don't have multiple user accounts set up and can disregard that. If you are using iTunes 11 go to View>Show Sidebar. Now see if your iPad appears under Devices on the left side when you connect it. If it does, click on the name of your iPad on the left side and your iTunes sync settings options will appear in folders with tabbed headings to the right.
If it doesn't appear on the left side, follow the troubleshooting steps shown in this article: http://support.apple.com/kb/TS1538. -
But it can auto sync when i connect it to my old laptop. what's the problem that it can't auto sync and when i did a backup in my new laptop, it was corrupted the next day and i was forced to use back a backup which i did in my old laptop 4 months ago. do i have to reinstall the itunes? will my backups be corrupted after i sync again? pls guide.
P.S/ its the latest version of the itunes whenever i did the backups.iPod touches or any iDevices from Apple sync only to one computer. If you sync to a different computer, all your music will be replace with the music from the new computer's iTunes. If the music were purchased from iTunes, you can re-download them again otherwise the music on iPod touch will be deleted. Do you have iTunes backup?
-
I can no longer connect to the iTunes Store on my laptop, what could the problem be?
I can no longer connect to the iTunes Store on my laptop, what could the problem be?
Hi curterb,
If you are having issues connecting to the iTunes Store, you may find the following article helpful:
Apple Support: Can't connect to the iTunes Store
http://support.apple.com/kb/TS1368
Regards,
- Brenden -
I connected my ipod touch 4g wi-fi with laptop ad hoc network....it's showing wi-fi signals but internet is not working...what is the problem in that can anyone help me...inadvances thanks
my laptop is Windows 7 and ip is this
192.168.102.12
255.255.255.0
192.168.102.1
DNS
192.168.254.2
192.168.254.3
in ipod touch 4g is DHCP and its showing
ip address 169.254.192.139
subnet mask 255.255.0.0.
remaining all blank -
trying to add Itunes match, and am almost at the end of installation when an error message pops up. it says error 4010 cannot connect to ittunes store at this time try again later. what is the problem?
Contact Apple support for warranty service.
-
My new macbook pro 13" just died and i can not turn it on. When i connect the power cort it also does nor charge. No light is commong on. I was working on battery power when it died and the battery was fully charged. What is the problem?
Take it back to the Apple Store for repair since it's still in warranty.
-
my iphone 4 will not charge in the plug or connect to my laptop but my ipod 4th gen does. what could the problem be because the screen to show it needs charging will not come up and it will not restart by holding the home button and lock button. thanks
Hi there,
I would recommend taking a look at the troubleshooting steps found in the article below.
iPhone: Hardware troubleshooting
http://support.apple.com/kb/ts2802
-Griff W -
I can't access to my ipad In MacBook Air. Error shows this device no loger connected or error shows that no response from divice and iTunes can't connected or not found divice, what's the problem? I reset my ipad but no response
Hi ..
Which OS X is installed on your Mac ?
Click the Apple () menu top left in your screen. From the drop down menu click About This Mac. The version is noted there.
Make sure your Mac OS X software is up to date.
Disconnect the iPad from your Mac.
Open System Preferences > Software Update > Check Now
If any updates are required, make sure to restart your Mac after the updates are installed then connect your iPad and see if iTunes recognizes it under Devices. -
I keep getting this message "Sync encountered an error while connecting: Failed to connect to the server. Please try again" What's the problem in English
Hi,
Sometimes the server is not available and you can get an error like this one. Usually it works if you try to sync later. If this doesn't work, take a look to [https://philikon.wordpress.com/2011/06/13/how-to-file-a-good-sync-bug/ this post] to learn how to report a bug.
Let me know if this is helpful. -
Recently when I connect my iphone 4 to my Mac for normal synchronising i found after a few minutes all my purchased apps were deleted and gone ? I have no problem to retrieve them back but that is exhausting and I am feeling sick ? what is the problem ? please help me and thank you
Make sure Sync Apps is checked on the Apps tab of your iTunes sync settings and that all the apps are checked that you want on your phone. Also be sure that your computer is authorized for all Apple IDs used to purchase your apps (and other media) in Store>Authorize this Computer.
-
I cannot connect to iPhone personal hotspot. What's the problem?
I have connected to iPhone hotspot using wifi and USB cord in the past. My current problem started with my wifi about a month ago. My wifi on my iPhone would not toggle on (grayed out) for about 2 weeks. After rebooting and restarting, I finally had to wipe phone clean and start hardware from new. After powering down several times over the following week, it surprisingly started working again. However, it will continue to go in & out sporadically. My iPad and loptop will recognize my iPhone's wifi, but will not connect. I can connect through USB cord and iPhone shows 1 connection, but laptop will not pick up connection. I have also tried to reentered password. All software is current. What's the problem?
Try the USB troublshooting tips here: http://support.apple.com/kb/ts2756
-
I need to go very very near to my wireless modem to find my network and if i go a little far i can not connect but before it was not like that?!what is the problem?!
Hey Babakgh,
I understand that you've experienced recent issues with your Wi-Fi network where you can only connect to it if you're close to the router. I would start off troubleshooting your Wi-Fi network by following the steps in here:
iOS: Troubleshooting Wi-Fi networks and connections
http://support.apple.com/kb/TS1398
Take care,
Delgadoh -
When I try to download a movie it says it will be ready for viewing in 10 hours. I am connected to wireless internet. What is the problem?
How fast is your internet connection and do you know what wireless standard your router is? Because download time will depend on several factors. The 1st one being the speed of your connection,2) the size of the file being downloaded,& 3) how fast your router send and receieve the data.
-
when i want to purchase or download an app it tells me. " unable to connect to itunes store." what is the problem?
Can't connect to the iTunes Store
Maybe you are looking for
-
Is there an jdev ARCS (appl. revision control system) extension available ?
Is there an ARCS ( application revision control system ) extension available for Jdeveloper ? Googling took me to OAF developer guide which said - "With the ARCS (Applications Revision Control System) Extension for JDeveloper, you can perform most so
-
Connecting webcam hd-3310 to a smart tv
Is it possible to connect an HP Webcam HD-3310 to a Samsung Smart TV and get the camera to work off of the TV? I know this model of webcam is not supported on all TVs. Thanks,
-
Hi all, I have a class that has a function that takes time to perform. This function reads data from a text file into an array. I need to notify the caller when the data is actually read so he may use another class member function to get them. Please
-
Unable to upgrade some songs to iTunes plus
Hello - I've seen some other discussions on this topic so I guess it's not an uncommon problem, but I wanted to ask about it anyway in case there are new insights about how to fix it! I have about 75 old "Protected AAC" songs - 128 bps DRM-protected
-
I need to update it on mcAfee but to do it i have to close the program but it doesent close
I need to update skype on McAfee but to do so I have to close skype but skype stays open all the time and i cant close it Help please!