Hi,
> 4. I use OracleConnectionPoolDataSource because with
>
javax.sql.DataSource it doesn't close correctly close connections from
> pool and server got to hang up.
Have you got any exception?
> 5. con variable is of type Connection. I found this in an example in
> google. May it be of type PooledConnection? If so, can I use pc variable
> instead of con?
I am using interface OracleConnection becouse sam libraries needs this
interface instead of Connection interface
> 6. I've putted user="test" password="test" in context but it still
> doesn't work if I don't put user and password in getPooledConnection.
>
> Currently context.xml is this:
>
> <Context debug="0" reloadable="true">
> <Resource
> name="jdbc/test" auth="Container"
> type="oracle.jdbc.pool.OracleConnectionPoolDataSource"
> factory="oracle.jdbc.pool.OracleDataSourceFactory"
> maxActive="5" maxIdle="-1" maxWait="-1"
> removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
> driverClassName="oracle.jdbc.OracleDriver"
> url="jdbc:oracle:thin:@(protected)" />
This is my resource:
<Resource name="IC"
auth="Container"
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
user="IC"
password="IC"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@(protected)"
maxActive="20" maxIdle="10" maxwait="-1"/>
> </Context>
>
> And code that gets the connection is this:
>
> Context initCtx = null;
> PooledConnection pc = null;
> Connection con = null;
>
> public void init()
> {
> if(pc == null)
> {
> try
> {
> initCtx = new InitialContext();
> Context ctx = (Context) initCtx.lookup("java:/comp/env");
> OracleConnectionPoolDataSource fuenteDatos =
> (OracleConnectionPoolDataSource) ctx.lookup("/jdbc/ganaderia");
> pc = fuenteDatos.getPooledConnection(dbUser, dbPassword);
> }
> catch(Exception e)
> {
> String mensaje = getMessage(e);
> sc.log(mensaje);
> }
> }
> initConnection();
> }
>
> void initConnection()
> {
> try
> {
> con = pc.getConnection();
> }
> catch(Exception e)
> {
> sc.log(getMessage(e));
> }
> }
>
> public void finishConnection()
> {
> try
> {
> if(con != null)
> {
> con.close();
> con = null;
> }
> }
> catch(Exception e)
> {
> sc.log(getMessage(e));
> con = null;
> }
> }
>
> public void finish()
> {
> try
> {
> finishConnection();
> if(pc != null)
> pc.close();
> }
> catch(Exception e)
> {
> sc.log(getMessage(e));
> }
> }
>
and this is my java code I use
try
{
// Look up the data source on the JNDI tree
DataSource ds = (DataSource) ctxt.lookup("java:/comp/env/" + poolName);
if (ds instanceof OracleDataSource)
{
log.debug("oracleDatasource found");
}
conn = ds.getConnection();
if (conn instanceof OracleConnection)
{
log.debug( "OracleConnection - delegated" );
}
}
catch ( Exception ex )
{
log.error( classId + "Error getting Oracle Connection.", ex );
throw ex;
}
What jdbc driver do you use?
And one question. Are you going to use any user transaction manager? :)
I use simpleJTA, but I have tested it only in developement...
Regards,
Zdenek
---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)