-
1. Re: DataSource problem - JBossManagedConnectionPool
mlange May 21, 2004 6:21 AM (in response to dakota007)I think the message is really self-explanatory: your pool is running out of connections.
-marek -
2. Re: DataSource problem - JBossManagedConnectionPool
dakota007 May 21, 2004 6:27 AM (in response to dakota007)This is the code:
package beans;
import java.sql.*;
import java.util.ArrayList;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class DbBean {
private static DataSource pool;
public static DataSource getPool() {
return pool;
}
public static void makePool() throws Exception{
try{
Context env = (Context) new InitialContext().lookup("java:comp/env");
//Look up a DataSource, which represents a connection pool
pool = (DataSource)env.lookup("jdbc/OracleDS");
if (pool == null)
throw new Exception("'OracleDS' is an unknown DataSource");
} catch (NamingException ne){
throw new Exception(ne.getMessage());
}
}
//method used for fetching data (only 1 column)
public ArrayList getSelect(String sql){
Statement st = null;
ArrayList arrList = new ArrayList();
Connection connection = null;
try {
connection = pool.getConnection();
st = connection.createStatement();
} catch (SQLException e1) {
e1.printStackTrace();
}
try{
ResultSet rs = st.executeQuery(sql);
while(rs.next()){
arrList.add(rs.getObject(1));
}
rs.close();
st.close();
connection.close();
}
catch (SQLException e) {
e.printStackTrace();
}
return arrList;
}
//method used for checking login access
public boolean getLogin(String sql) {
Statement st = null;
ResultSet rs = null;
boolean found = false;
Connection connection = null;
try {
connection = pool.getConnection();
st = connection.createStatement();
rs = st.executeQuery(sql);
if (rs.next())
found = true;
else
found = false;
rs.close();
st.close();
connection.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
return found;
}
}
When I say connection.close() , the connection is given back to the pool. Am I wrong ? How is it possible that my pool is running out of connections? -
3. Re: DataSource problem - JBossManagedConnectionPool
lepe May 21, 2004 6:49 AM (in response to dakota007)Every time you have an SQLException you will not close the connection. Instead do all those closing in a finally block.
/L -
4. Re: DataSource problem - JBossManagedConnectionPool
adrian.brock May 21, 2004 7:10 AM (in response to dakota007) -
5. Re: DataSource problem - JBossManagedConnectionPool
dakota007 May 21, 2004 7:20 AM (in response to dakota007)Thank you very much to all for the quick responses :-)
Now it works
Frederic -
6. Re: DataSource problem - JBossManagedConnectionPool
adrian.brock May 21, 2004 7:23 AM (in response to dakota007)And now for your problem specfically:
http://www.jboss.org/wiki/Wiki.jsp?page=WhatDoesTheMessageNoManagedConnectionsAvailableMean -
7. Re: DataSource problem - JBossManagedConnectionPool
mdpatil Feb 22, 2007 10:45 PM (in response to dakota007)i am also getting same error but when i am increasing the pool size.
In my oracle-ds.xml minimum size is 10 and maximum size is 50.