Please iam new to java and jsp and want to implement this message but it show me that there is no connection
so could any one implement it and tell me what is the problem
the code is place down
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.bean;
public synchronized Connection getConnection() throws SQLException {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(URL, user, password);
freeConnections = new Vector(maxConn);
if (freeConnections.size() > 0) {
// Pick the first Connection in the Vector
// to get round-robin usage
con = (Connection) freeConnections.firstElement();
freeConnections.removeElementAt(0);
try {
if (con.isClosed()) {
log("Removed bad connection from " + name);
// Try again recursively
con = getConnection();
}
} catch (SQLException e) {
log("Removed bad connection from " + name);
// Try again recursively
con = getConnection();
}
} else if (maxConn == 0 || checkedOut < maxConn) {
con = newConnection();
}
if (con != null) {
checkedOut++;
}
private Connection newConnection() {
Connection con = null;
try {
if (user == null) {
con = DriverManager.getConnection(URL);
} else {
con = DriverManager.getConnection(URL, user, password);
}
log("Created a new connection in pool " + name);
} catch (SQLException e) {
log(e, "Can't create a new connection for " + URL);
return null;
}
return con;
}
/////////////////////////////////////////////////
public synchronized Connection getConnection(long timeout) throws SQLException {
long startTime = new Date().getTime();
Connection con;
while ((con = getConnection()) == null) {
try {
wait(timeout);
} catch (InterruptedException e) {
}
if ((new Date().getTime() - startTime) >= timeout) {
// Timeout has expired
return null;
}
}
return con;
}
///////////////////////////////////////////////////////
public synchronized void freeConnection(Connection con) {
// Put the connection at the end of the Vector
freeConnections.addElement(con);
checkedOut--;
notifyAll();
}
///////////////////////////////////////////////////////
public synchronized void release() {
Enumeration allConnections = freeConnections.elements();
while (allConnections.hasMoreElements()) {
Connection con = (Connection) allConnections.nextElement();
try {
con.close();
log("Closed connection for pool " + name);
} catch (SQLException e) {
log(e, "Can't close connection for pool " + name);
}
}
freeConnections.removeAllElements();
}
///////////////////////////////////////////////////////
}