commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj <rajsh...@yahoo.com>
Subject Re: DBCP POOL -Connection Pool giving nullpointer -->Unable to intialize -->Crashing
Date Thu, 06 May 2004 20:50:57 GMT
We are using commons-pool-1.1.jar and
commons-dbcp-1.1.jar
Do you think I have to change MAX Active to some more
number like 300 or some thing and add 

MAXIdle
MInIdle
WHEN_EXHAUSTED_GROW
and also 
connectionPool.setNumTestsPerEvictionRun(20);
connectionPool.setMinEvictableIdleTimeMillis(600000);
connectionPool.setTimeBetweenEvictionRunsMillis(10000);
// 10 sec

Please let me know...
Here are the files..
this jsp calls DBConnection which inturn call
datasourcefactory function to initialize connection.
frmTestConnectionPool.jsp START
**********-----------
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="***.***.***.jdbc.*" %>
<%@ page import="***.***.***.DBConnection" %>
<%@ page
import="org.apache.commons.dbcp.PoolingDataSource" %>
<%@ page
import="org.apache.commons.dbcp.PoolingDriver" %>
<%@ page import="org.apache.commons.pool.ObjectPool"
%>

<title>Support: Connection Pool</title>
<% try {
	// start Application
	applicationStart( globalContext, log, literal,
profiler);    
} catch (Exception e) {
	logger.writeError(e.toString());
}
%>
<br><br>
<table cellSpacing="0" cellPadding="0" border="0">
<tbody>
	<tr>
		<td>
			<table border="0" cellpadding="2" cellspacing="0">
			<tr><td><font class="pageheader"> Connection
Pooling Test</td></tr>
			</table>
		</td>
	</tr>
    <tr>
		<td valign="top" align="left" width="533"
class="largebody">
			<table border="0" cellpadding="2" cellspacing="0">
			<tr><td><img src="/images/2.0/main.jpg" width="533"
height="150"></td></tr>
			<tr><td>&nbsp;</td></tr>
			</table>
			<%-- Begin body content --%> 
<%
     	DBConnection objCase = null;
	ResultSet objCaseRs = null;
try {
   	objCase = new DBConnection();
	int id = 0;
	objCaseRs = objCase.executeQuery("select count(*)
from sw_case");
	if(objCaseRs != null) {
		if(objCaseRs.next()){
		   id = objCaseRs.getInt(1);
			%>
				<%="CASE COUNT: " + id %>
			<%
		}
	}
} 
catch (Exception e) {
		StackTraceElement[] st = e.getStackTrace();
		StackTraceElement st2 = null;
		log.addEntry(" frmTestConnectionPool.jsp ",
Log.LOG_SEVERITY_ERROR, e.toString());
		for(int i=0; i< st.length; i++) {
			st2 = st[i];
			log.addEntry(" frmTestConnectionPool.jsp  ",
st2.toString());
		}
		throw e;
} finally {
	objCase.closeAllIgnoreExceptions();
}
%>  
			<%-- End body content --%>
		</td>
		<td width="20"><img height=3 alt=""
src="/images/2.0/px_transparent.gif" width=20
border=0></td>
		<td width=162 align=left valign="top">
		<%@include file="/include/promos/incExtPromos.jsp"%>
				</td>
			</tr>
			<tr><td colspan="3" height="1"
valign="top">&nbsp;&nbsp;</td></tr>
			<tr><td colspan="3" height="1" valign="top"><spacer
type="block" width="1" height="1"/></td></tr>
			<tr><td colspan="3" height="4"><img
src="/images/2.0/clearpixel.gif" width="1"
height="4"></td></tr>
			</table>
<%@ include file="/include/layout/endLayout.jsp" %>
******  frmTestConnectionPool.jsp END -----

***** DBConnection setup ----
 	private void setupEnvironment() throws Exception {
 		context = new InitialContext();
 		ds =
***.***.****.jdbc.DataSourceFactory.getDataSource();
 		con = ds.getConnection();
 	}
*******-----


DATASOURCEFACTORY java
public class DataSourceFactory  {
    private static DataSource ds = null;
    public static synchronized DataSource
getDataSource() {
      if (ds == null) {
        setup();
      }
      return ds;
    }
    static void setup() {
        try {
           
Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e) {
          throw new LoggedError(e);
        }
        // read defaults from properties file
        Properties p =
PropertiesManager.getProperties("jdbc");
        String driver =
p.getProperty("**.***.***.jdbc.driver");
        String auth =
p.getProperty("**.***.***.jdbc.auth");
        String server =
p.getProperty("**.***.***.jdbc.db");

        String connectURI = driver + ":" + auth + "@"
+ server;
        // setup data source
        ds = setupDataSource(connectURI);
    }
    private static DataSource setupDataSource(String
connectURI) {
        String testStr = "SELECT COUNT(*) FROM DUAL";
        GenericObjectPool connectionPool = new
GenericObjectPool(null);
        ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(connectURI,null);
        new
PoolableConnectionFactory(connectionFactory,connectionPool,null,testStr,false,true);
        // set up pool options
        connectionPool.setTestOnBorrow(true);
        connectionPool.setTestOnReturn(true);
        connectionPool.setMaxActive(50);
       
connectionPool.setWhenExhaustedAction(connectionPool.WHEN_EXHAUSTED_FAIL);
        PoolingDataSource dataSource = new
PoolingDataSource(connectionPool);
        return dataSource;
    }
}
*****************************END DATASOURCEFACTORY
------------

DIrk...Thanks very much for your help in advance.
Regards..RAJ

--- Dirk Verbeeck <dirk.verbeeck@pandora.be> wrote:
> DBCP version? (1.0, 1.1, nightly)
> 
> Normally you should get a SQLException even when the
> pool is empty.
> Can you post your frmTestConnectionPool.jsp?
> 
> -- Dirk
> 
> raj wrote:
> 
> > Hello,
> > We have been using jakarta pool implementation
> with
> > JRUN for past 6 months and worked fine until last
> > week.
> > Started giving this error.
> > 
> > Works fine for couple of hours and starts crashing
> and
> > had to restart JRUN every time.
> > 
> > Explanation from our admin -->
> > Load on database causing delay in getting
> connection
> > from connection pool which is becoming stale after
> > trying to get connection for long time.
> > I did not like this explanation as nothing changed
> and
> > started suddenly.
> > ANY HELP WILL BE REALLY APPRECIATED and THANKS FOR
> > YOUR TIME.
> > 
> > These are the parameters for connection pool      
> 
> > GenericObjectPool connectionPool = new
> > GenericObjectPool(null);
> >         ConnectionFactory connectionFactory = new
> > DriverManagerConnectionFactory(connectURI,null);
> >         new
> >
>
PoolableConnectionFactory(connectionFactory,connectionPool,null,testStr,false,true);
> > 
> >         // set up pool options
> > 
> >         
> >         connectionPool.setTestOnBorrow(true);
> >         connectionPool.setTestOnReturn(true);
> >         connectionPool.setMaxActive(50);
> >        
> >
>
connectionPool.setWhenExhaustedAction(connectionPool.WHEN_EXHAUSTED_FAIL);
> > 
> >         PoolingDataSource dataSource = new
> > PoolingDataSource(connectionPool);
> > 
> > --> This is stacktrace from the JSP -->
> > 
> > 
> > 05/04/2004 06:03:06 PM 
> > /temp/frmTestConnectionPool.jsp Error           0 
>    
> >  Testing 
> > 05/04/2004 06:03:06 PM 
> > /temp/frmTestConnectionPool.jsp Error           0 
>    
> >  Testing 2 
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Error           0      
> > java.lang.NullPointerException
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
com.nokia.support.DBConnection.printStackTraceToLog(DBConnection.java:925)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
com.nokia.support.DBConnection.<init>(DBConnection.java:349)
> >   ----->
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
jrun__temp__frmTestConnectionPool2ejsp1f._jspService(jrun__temp__frmTestConnectionPool2ejsp1f.java:807)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:39)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:228)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:196)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JRunSE.service(JRunSE.java:1417)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.session.JRunSessionService.service(JRunSessionService.java:1088)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:1271)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:89)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JRunSE.service(JRunSE.java:1557)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JRunSE.service(JRunSE.java:1547)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:364)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
>
allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:388)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> > allaire.jrun.ThreadPool.run(ThreadPool.java:272)
> > 05/04/2004 06:03:06 PM   frmTestConnectionPool.jsp
>    
> >  Information     0      
> >
> allaire.jrun.WorkerThread.run(WorkerThread.java:75)
> > 05/04/2004 06:03:06 PM 
> > /temp/frmTestConnectionPool.jsp Error           0 
>    
> >  Testing 7 
> > 
> > 
> > 
> > THANKS very much--
> > RAJ
> > 
> > 
> > 	
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Win a $20,000 Career Makeover at Yahoo! HotJobs  
> >
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> > 
> > 
> > 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message