DBCP Question

2002-09-24 Thread Amitabh Dubey

Hello all,
   if i do not specify any factory in my server.xml, i believe that tomcat
uses DBCP by default. This is fine, but I have a few questions.

This is what my server.xml looks like

  
  
validationQuery

  
  
user
sa
  
  
maxWait
5000
  
  
maxActive
5
  
  
password
sa
  
  
url

jdbc:microsoft:sqlserver://dnas07:1113;DatabaseName=Northwind
  
  
driverClassName
com.microsoft.jdbc.sqlserver.SQLServerDriver
  
  
maxIdle
10
  


If this file is correct, then why do i see the number of connections to the
database go more than 10, when maxActive is 10?

Does the driverClassName have to be a DataSource or is the above correct?

In my client code, after i lookup the name, do i have to cast my DataSource
to a ConnectionPoolDataSource?

Any kind of help would be great.

Thanks
Amitabh


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




DBCP question

2002-12-04 Thread Veniamin Fichin
Hello cats!

I'm trying to implement connection pool with Oracle8 database. After 
some codewriting I stuck with a problem which I don't know how to solve. 
Here are my configs and source code.

--= [ server.xml ] =--

 
  
 port="8080"
 minProcessors="5"
 maxProcessors="75"
 enableLookups="true"
 acceptCount="10"
 debug="0"
 connectionTimeout="2"
 useURIValidationHack="false" />
  
   
   prefix="catalina_log." suffix=".txt"
   timestamp="true" />
   
 debug="0"
 appBase="webapps"
 unpackWARs="true" autoDeploy="true">

directory="logs"  prefix="localhost_log." suffix=".txt"
timestamp="true" />

 reloadable="true">

 
   type="oracle.jdbc.pool.OracleConnectionPoolDataSource"
   auth="Container"
   description="Oracle database resource for esljsp project" />
 
  
   dataSourceName
   oracle.jdbc.pool.OracleDataSource
  
  
   description
   Oracle database resource for esljsp project
  
  
   serverName
   db.server.ru
  
  
   portNumber
   1521
  
  
   networkProtocol
   tcp
  
  
   databaseName
   sidvalue
  
  
   user
   username
  
  
   password
   password
  
 
 
 prefix="localhost_esljsp_log." suffix=".txt"
 timestamp="true" />

   
  
 

--= [ / server.xml ] =--

--= [ / web.xml ] =--


 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd";
>


 
  DBAccessTest
  ru.rbcsoft.esljsp.DBAccessTest
 
 

  DBAccessTest
  /dbaccess/DBAccessTest
 
 
  Oracle database resource for esljsp project
  jdbc/esljsp-oracle
  oracle.jdbc.pool.OracleConnectionPoolDataSource
  Container
  Unshareable
 

--= [ / web.xml ] =--

--= [ index.jsp ] =--
<%@ page isThreadSafe="false" info="Database access test|Index page"
 contentType="text/html; charset=utf-8" %>
<%@ page import="javax.naming.InitialContext, javax.naming.Context" %>
<%@ page import="oracle.jdbc.pool.OracleConnectionPoolDataSource" %>

 
  Database access test: index page
 
 
<%
Context ctx=new InitialContext();
OracleConnectionPoolDataSource oracpds=

(OracleConnectionPoolDataSource)ctx.lookup("java:comp/env/jdbc/esljsp-oracle");
out.print(oracpds);
%>
 

--= [ index.jsp ] =--

And I get this error:

javax.servlet.ServletException: Cannot create resource instance

But DBAccessTest servlet, mentioned above, cat instantiate 
OracleConnectionPoolDataSource.

As I understand, there is at leave to way to implement dbcp -- Tomcat 
way (org.apache.commons.dbcp.BasicDataSourceFactory) and Oracle way, and 
I've chosen wrong one. But I still want it to be done with Oracle 
implementation.
If there are any solid reasons that Tomcat way is better (except of 
interportability), I would love to hear them all!


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 



RE: DBCP question

2002-12-05 Thread Roberts, Eric
Hi Veniamin,

Try this way instead - it works for me!

Server.xml:

.
.

.
.

driverClassName
oracle.jdbc.driver.OracleDriver


factory
org.apache.commons.dbcp.BasicDataSourceFactory


url
jdbc:oracle:thin:@db.server.ru:1521:sidvalue
.
.

web.xml:
.
.
  
   Oracle database resource for esljsp project
   jdbc/esljsp-oracle
   javax.sql.DataSource
   Container
  
.
.

Source:
.
.
import javax.naming.Context;
import javax.naming.InitialContext;
.
.
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:/comp/env/");
DataSource ds = (DataSource) envCtx.lookup("/esljsp-oracle");

Hope this helps!

-Original Message-
From: Veniamin Fichin [mailto:[EMAIL PROTECTED]]
Sent: Mittwoch, 04. Dezember 2002 20:28
To: Tomcat Users List
Subject: DBCP question


Hello cats!

I'm trying to implement connection pool with Oracle8 database. After 
some codewriting I stuck with a problem which I don't know how to solve. 
Here are my configs and source code.

--= [ server.xml ] =--

  
   
   


 
 

  
  
   
dataSourceName
oracle.jdbc.pool.OracleDataSource
   
   
description
Oracle database resource for esljsp project
   
   
serverName
db.server.ru
   
   
portNumber
1521
   
   
networkProtocol
tcp
   
   
databaseName
sidvalue
   
   
user
username
   
   
password
password
   
  
  
 

   
  

--= [ / server.xml ] =--

--= [ / web.xml ] =--

http://java.sun.com/dtd/web-app_2_3.dtd";
 >


  
   DBAccessTest
   ru.rbcsoft.esljsp.DBAccessTest
  
  

   DBAccessTest
   /dbaccess/DBAccessTest
  
  
   Oracle database resource for esljsp project
   jdbc/esljsp-oracle
   oracle.jdbc.pool.OracleConnectionPoolDataSource
   Container
   Unshareable
  

--= [ / web.xml ] =--

--= [ index.jsp ] =--
<%@ page isThreadSafe="false" info="Database access test|Index page"
  contentType="text/html; charset=utf-8" %>
<%@ page import="javax.naming.InitialContext, javax.naming.Context" %>
<%@ page import="oracle.jdbc.pool.OracleConnectionPoolDataSource" %>

  
   Database access test: index page
  
  
<%
Context ctx=new InitialContext();
OracleConnectionPoolDataSource oracpds=
 
(OracleConnectionPoolDataSource)ctx.lookup("java:comp/env/jdbc/esljsp-oracle");
out.print(oracpds);
%>
  

--= [ index.jsp ] =--

And I get this error:

javax.servlet.ServletException: Cannot create resource instance

But DBAccessTest servlet, mentioned above, cat instantiate 
OracleConnectionPoolDataSource.

As I understand, there is at leave to way to implement dbcp -- Tomcat 
way (org.apache.commons.dbcp.BasicDataSourceFactory) and Oracle way, and 
I've chosen wrong one. But I still want it to be done with Oracle 
implementation.
If there are any solid reasons that Tomcat way is better (except of 
interportability), I would love to hear them all!


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: DBCP question

2002-12-06 Thread Veniamin Fichin
Roberts, Eric wrote:


Try this way instead - it works for me!


Thanks, I'll try it. I just thought that I cat use Oracle dbcp 
implementation only, without BasicDataSourceFactory Tomcat alternative.

Server.xml:

.
.

.
.

driverClassName
oracle.jdbc.driver.OracleDriver


factory
org.apache.commons.dbcp.BasicDataSourceFactory


url
jdbc:oracle:thin:@db.server.ru:1521:sidvalue
.
.

web.xml:
.
.
  
   Oracle database resource for esljsp project
   jdbc/esljsp-oracle
   javax.sql.DataSource
   Container
  
.
.

Source:
.
.
import javax.naming.Context;
import javax.naming.InitialContext;
.
.
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:/comp/env/");
DataSource ds = (DataSource) envCtx.lookup("/esljsp-oracle");

Hope this helps!


--= [ original post cut ] =--


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




common dbcp question

2003-12-05 Thread Michal N Lusztig
 I inherited a very badly writen Tomcat4.1 application, where the 
developer is not
closing connections, relying rather on configuration parameters for the 
dbcp pool to take care of removing abandoned connections. Is such a 
strategy supposed to work ? If yes, what are the configuration 
parameters that would solve this problem ? Reading the
documentation in DBCP dataSource, it looks like remove_abandoned is 
depracated !

Miki

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: common dbcp question

2003-12-05 Thread Chaikin, Yaakov Y (US SSA)
Check out "Preventing dB connection pool leaks" at:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations

HTH

Yaakov Chaikin
Software Engineer
BAE SYSTEMS
301-838-6899 (phone)
301-838-6802 (fax)
[EMAIL PROTECTED]


> -Original Message-
> From: Michal N Lusztig [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 05, 2003 11:29 AM
> To: [EMAIL PROTECTED]
> Subject: common dbcp question
> 
>   I inherited a very badly writen Tomcat4.1 application, where the
> developer is not
> closing connections, relying rather on configuration parameters for
the
> dbcp pool to take care of removing abandoned connections. Is such a
> strategy supposed to work ? If yes, what are the configuration
> parameters that would solve this problem ? Reading the
> documentation in DBCP dataSource, it looks like remove_abandoned is
> depracated !
> 
> 
> Miki
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: common dbcp question

2003-12-05 Thread Daniele Innocenti
In an application I was writing I forgot closing some connections.
Despite the fact I had configured Tomcat as the example shows, no 
connections was ever released.
Solutions was simple, writing better code. But I wonder if remove-abandoned 
actually do what it is supposed to.
Has anyone used it with success?

P.S. MySQL Connector\j version was j3.0

Daniele

At 20.50 05/12/2003, you wrote:
Check out "Preventing dB connection pool leaks" at:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations
HTH

Yaakov Chaikin
Software Engineer
BAE SYSTEMS
301-838-6899 (phone)
301-838-6802 (fax)
[EMAIL PROTECTED]
> -Original Message-
> From: Michal N Lusztig [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 05, 2003 11:29 AM
> To: [EMAIL PROTECTED]
> Subject: common dbcp question
>
>   I inherited a very badly writen Tomcat4.1 application, where the
> developer is not
> closing connections, relying rather on configuration parameters for
the
> dbcp pool to take care of removing abandoned connections. Is such a
> strategy supposed to work ? If yes, what are the configuration
> parameters that would solve this problem ? Reading the
> documentation in DBCP dataSource, it looks like remove_abandoned is
> depracated !
>
>
> Miki
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]