You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by josh <jo...@ink.org> on 2004/07/27 20:47:04 UTC

ibatis and jndi pooling

I am trying to figure out how to use sqlmaps and struts.  Before sqlMaps
I would create a connection to the database using a plugin.  In my
init() I did something like this

this.ds = (DataSource) context.lookup("java:comp/env/" + lookupString);

This gave me a datasource object that I could use for my app, and I
could close the connection in the destroy() method of the plugin to be
sure that my connections would get closed up if tomcat were to be
restarted.

Now that I use sqlMaps I still use a plugin, but there is no equivalent
close function to use in the destroy() method of the plugin.  This means
that if I remove my app from the server or restart it the old DB
connection gets orphaned but doesn't die.  And meanwhile my app gets a
new connection to the DB.  How do other people deal with this?  Am I
doing this completely wrong?  I can't find anything in the sqlMaps
documentation about this.

 
-- 
Joshua Cronemeyer
Developer
accessKansas - a service of the Information Network of Kansas, Inc.
www.accesskansas.org <http://www.accesskansas.org/>
785-296-2816 (phone)
785-296-5563 (fax)
josh@ink.org <ma...@ink.org>

***********************
CONFIDENTIALITY NOTICE:
This E-mail and any attachments are confidential.  If you are not the
intended recipient, you do not have permission to disclose, copy,
distribute, or open any attachments.  If you have received this E-mail
in
error, please notify us immediately by returning it to the sender and
delete
this copy from your system.

Thank you.
accessKansas
***********************

Re: OT: Re: ibatis and jndi pooling

Posted by Vic Cekvenich <ce...@portalvu.com>.
So I think Clinton answerd your question there, so done!?
.V

josh wrote:
> vic,
> 
> I have moved everything to the Ibatis forum.  You are right, the
> discussion has very little struts specific information unless someone
> else is interested in the discussion about plugins or how to properly
> manage the db connection (of which I could use some guidance)
> 
> I posted my reply to your last email in the forum.
> 
> -josh
> 
> On Tue, 2004-07-27 at 18:33, Vic Cekvenich wrote:
> 
>>josh wrote:
>>  I just get a reference to the datasource and close it in
>>
>>>the destroy method of the plugin.  
>>
>>Let me ask why do you get a reference to datasource in SqlMaps?
>>
>>You can do ANYTHING with just:
>>
>>             List rows =_sqlMap.queryForList("mapNam", parms);
>>
>>
>>(also... the iBatis forum is VERY good and VERY active and we might want 
>>to move the thread there)
>>.V
>>
>>
>>If I don't do this, and my
>>
>>>application gets reloaded many times, then I leave behind many
>>>connections to the DB forcing me to bring down tomcat in order to close
>>>them (for my DB admin who gets irate).
>>>
>>>It makes me think that I am not doing something at the server level that
>>>I should be doing.  Any ideas?
>>>
>>>cheers,
>>>josh
>>>On Tue, 2004-07-27 at 14:31, Vic Cekvenich wrote:
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org


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


Re: OT: Re: ibatis and jndi pooling

Posted by josh <jo...@ink.org>.
vic,

I have moved everything to the Ibatis forum.  You are right, the
discussion has very little struts specific information unless someone
else is interested in the discussion about plugins or how to properly
manage the db connection (of which I could use some guidance)

I posted my reply to your last email in the forum.

-josh

On Tue, 2004-07-27 at 18:33, Vic Cekvenich wrote:
> josh wrote:
>   I just get a reference to the datasource and close it in
> > the destroy method of the plugin.  
> 
> Let me ask why do you get a reference to datasource in SqlMaps?
> 
> You can do ANYTHING with just:
> 
>              List rows =_sqlMap.queryForList("mapNam", parms);
> 
> 
> (also... the iBatis forum is VERY good and VERY active and we might want 
> to move the thread there)
> .V
> 
> 
> If I don't do this, and my
> > application gets reloaded many times, then I leave behind many
> > connections to the DB forcing me to bring down tomcat in order to close
> > them (for my DB admin who gets irate).
> > 
> > It makes me think that I am not doing something at the server level that
> > I should be doing.  Any ideas?
> > 
> > cheers,
> > josh
> > On Tue, 2004-07-27 at 14:31, Vic Cekvenich wrote:
> > 
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
-- 
Joshua Cronemeyer
Developer
accessKansas - a service of the Information Network of Kansas, Inc.
www.accesskansas.org <http://www.accesskansas.org/>
785-296-2816 (phone)
785-296-5563 (fax)
josh@ink.org <ma...@ink.org>

***********************
CONFIDENTIALITY NOTICE:
This E-mail and any attachments are confidential.  If you are not the
intended recipient, you do not have permission to disclose, copy,
distribute, or open any attachments.  If you have received this E-mail
in
error, please notify us immediately by returning it to the sender and
delete
this copy from your system.

Thank you.
accessKansas
***********************


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


OT: Re: ibatis and jndi pooling

Posted by Vic Cekvenich <ce...@portalvu.com>.
josh wrote:
  I just get a reference to the datasource and close it in
> the destroy method of the plugin.  

Let me ask why do you get a reference to datasource in SqlMaps?

You can do ANYTHING with just:

             List rows =_sqlMap.queryForList("mapNam", parms);


(also... the iBatis forum is VERY good and VERY active and we might want 
to move the thread there)
.V


If I don't do this, and my
> application gets reloaded many times, then I leave behind many
> connections to the DB forcing me to bring down tomcat in order to close
> them (for my DB admin who gets irate).
> 
> It makes me think that I am not doing something at the server level that
> I should be doing.  Any ideas?
> 
> cheers,
> josh
> On Tue, 2004-07-27 at 14:31, Vic Cekvenich wrote:
> 
>


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


Re: ibatis and jndi pooling

Posted by josh <jo...@ink.org>.
vic,

thanks for the reply.  let me clarify my problem.  When I create a
connection to the db using connection pooling (as illustrated in my
first email) I could do something like the following...

Connection conn = ds.getConnection();

... use this connection to access the database ...

conn.close();

but this doesn't really close anything, rather it returns the connection
back to the pool for later use.  So that is why I always did something
like this in the destroy method of my plugin...

((BasicDataSource) ds).close();

That would actually kill the connection to the DB after my application
was removed or reloaded on the server.  It turns out that this works for
sqlMaps too.  I just get a reference to the datasource and close it in
the destroy method of the plugin.  If I don't do this, and my
application gets reloaded many times, then I leave behind many
connections to the DB forcing me to bring down tomcat in order to close
them (for my DB admin who gets irate).

It makes me think that I am not doing something at the server level that
I should be doing.  Any ideas?

cheers,
josh
On Tue, 2004-07-27 at 14:31, Vic Cekvenich wrote:
> josh wrote:
> > I am trying to figure out how to use sqlmaps and struts.  Before sqlMaps
> > I would create a connection to the database using a plugin.  In my
> > init() I did something like this
> > 
> > this.ds = (DataSource) context.lookup("java:comp/env/" + lookupString);
> > 
> > This gave me a datasource object that I could use for my app, and I
> > could close the connection in the destroy() method of the plugin to be
> > sure that my connections would get closed up if tomcat were to be
> > restarted.
> > 
> > Now that I use sqlMaps I still use a plugin, but there is no equivalent
> > close function to use in the destroy() method of the plugin. 
> 
> It's becuase SQL maps does it for you!
> 
> You should try it just making connections in SQL maps for now.
> Then, if you want move to having container making a DataSourcePool and 
> SQLMaps just using that pool.
> .V
> 
>   This means
> > that if I remove my app from the server or restart it the old DB
> > connection gets orphaned but doesn't die.  And meanwhile my app gets a
> > new connection to the DB.  How do other people deal with this?  Am I
> > doing this completely wrong?  I can't find anything in the sqlMaps
> > documentation about this.
> > 
> >  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
-- 
Joshua Cronemeyer
Developer
accessKansas - a service of the Information Network of Kansas, Inc.
www.accesskansas.org <http://www.accesskansas.org/>
785-296-2816 (phone)
785-296-5563 (fax)
josh@ink.org <ma...@ink.org>

***********************
CONFIDENTIALITY NOTICE:
This E-mail and any attachments are confidential.  If you are not the
intended recipient, you do not have permission to disclose, copy,
distribute, or open any attachments.  If you have received this E-mail
in
error, please notify us immediately by returning it to the sender and
delete
this copy from your system.

Thank you.
accessKansas
***********************


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


Re: ibatis and jndi pooling

Posted by Vic Cekvenich <ce...@portalvu.com>.
josh wrote:
> I am trying to figure out how to use sqlmaps and struts.  Before sqlMaps
> I would create a connection to the database using a plugin.  In my
> init() I did something like this
> 
> this.ds = (DataSource) context.lookup("java:comp/env/" + lookupString);
> 
> This gave me a datasource object that I could use for my app, and I
> could close the connection in the destroy() method of the plugin to be
> sure that my connections would get closed up if tomcat were to be
> restarted.
> 
> Now that I use sqlMaps I still use a plugin, but there is no equivalent
> close function to use in the destroy() method of the plugin. 

It's becuase SQL maps does it for you!

You should try it just making connections in SQL maps for now.
Then, if you want move to having container making a DataSourcePool and 
SQLMaps just using that pool.
.V

  This means
> that if I remove my app from the server or restart it the old DB
> connection gets orphaned but doesn't die.  And meanwhile my app gets a
> new connection to the DB.  How do other people deal with this?  Am I
> doing this completely wrong?  I can't find anything in the sqlMaps
> documentation about this.
> 
>  


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