AW: DataSource Casting Problem

2002-07-15 Thread Maier Holger, ITS-AKIS

Hi,
I am also struggling with ConnectionPool
at the moment. I have an Informix DB to connect to.

 It works if I use this:
 org.apache.commons.dbcp.BasicDataSource ds=
  (org.apache.commons.dbcp.BasicDataSource) 
 envCtx.lookup(jdbc/ospreyDb);

 Any ideas? Thanks a lot in advance!
How is your configuration of the DS in your server.xml?
Did you define a factory for your DataSource,
i.e. 
parameter
  namefactory/name
  valuecom.informix.jdbcx.IfxDataSourceFactory/value
/parameter

for DBCP the value is probably
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value

Then you can probaly do without defining
 org.apache.commons.dbcp.BasicDataSource ds
and using DataSource ds instead.

Hope that helps,
Cheers
Holger

-
Holger Maier  Tel.:  (06831) 47-3497
ITS-AKIS  eMail: [EMAIL PROTECTED]

AG der Dillinger Hüttenwerke
Postfach 1580
66748 Dillingen


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




DataSource Access - Design Question

2002-07-15 Thread Maier Holger, ITS-AKIS

Hi,
I am trying to get my DataSource 
(with Connection Pooling) to run.

In the examples one always gets the 
DataSource from JNDI and I have the 
impression that everytime I want
to get my connection from DataSource
via a Context lookup.

Wouldn't it be better to read the
data source once in a singleton class
and then just get it back, i.e. 

private DataSource ds;
...
public static void getDataSource() {
   // if data source unknown read it from context
   if (ds == null) {
 try {
   Context ctx = new InitialContext();
   ds = (DataSource) ctx.lookup(java:comp/env/jdbc/myDataSource);
 }
 catch (..) {..}
   }
 
   return ds;   
}

This should be faster than accessing the context
every time you need a datasource or a connection.

Could this lead into problems?
Any suggestions?

Cheers,
Holger

-
Holger Maier  Tel.:  (06831) 47-3497
ITS-AKIS  eMail: [EMAIL PROTECTED]

AG der Dillinger Hüttenwerke
Postfach 1580
66748 Dillingen


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