Depends on your situation.
If the SQL Exceptions are expected (i.e., a trigger could fail) then
yes, you will want to catch that and send the message back to the user.
However, if you are thinking JDBC is the way to go, you really should
use something like iBATIS that hides this kind of stuff fr
ED]>
> Data: Wed, 07 Apr 2004 09:00:16 -0400
> Para: Struts Users Mailing List <[EMAIL PROTECTED]>
> Assunto: Re: Connection Pooling (How i use...)
>
> So, are there implied catches in there for SQLException (I assume there
> are)?
> In the innermost try block, does t
So, are there implied catches in there for SQLException (I assume there
are)?
In the innermost try block, does the catch rethrow the SQLException so that
it cascades to the outer blocks?
Just trying to understand the model.
Dean Hoover
Larry Meadors wrote:
Yes.
You really might want to consi
List
Emne: Re: Connection Pooling (How i use...)
I use the pool like this: (IS IT WRONG??) I think the connection is
being closed..
try {
Context ctx = new InitialContext();
if (ctx == null)
throw new Exception("Boom - No Context");
Dat
See this
Connection conn = null;
try{
conn = ds.getConnection();
...whatever you wish to do with conn..
catch(SQLException sqle)
{
action of exception
}
finally{
try{
if(nul != conn) conn.close();
}
catch(SQLException sqle){ action of except
Uhh, yeah, I never did that, no, I just heard about it...yeah, that's
it...
;-)
>>> [EMAIL PROTECTED] 04/06/04 11:45 AM >>>
*Quite* right: there was one time we had set the autoCommit on the
connection object to false, forgotten to change it back before releasing
it
to the pool andwell,all
*Quite* right: there was one time we had set the autoCommit on the
connection object to false, forgotten to change it back before releasing it
to the pool andwell,all I can say is we spent some "interesting" hours
trying to debug that one!
Geeta
Larry Meadors wrote:
> Yes.
>
> So be careful
Oh yeah, that reminds me: Be careful not to double close your
connections - with some implementations, that closes the pool.
So do not close the connectionin the try *and* in the finally - do it
*only* in the finally!
Larry
>>> [EMAIL PROTECTED] 04/06/04 11:25 AM >>>
well, you are right...! Wh
Ah, well, you didn't read the fine print:
-->>Note: this code isn't anywhere near production ready - it's only supposed to be
used as a simple test :-)
Believe me, you should close connections/return them to the pool in a finally block if
you want to avoid major
problems.. As I said before, thi
I have yet to see a *good* example of how to do jdbc on the net.
Most are very simple one-off "throws SQLException" examples that don't
seem to take into consideration little things like stability and
releasing resources. :)
That is why I think tools like iBATIS are so powerful - you get all the
Yes.
So be careful if you tweak the connection (like changing transaction
isolation, etc) because that connection may be used elsewhere, and your
change will persist. :)
Larry
>>> [EMAIL PROTECTED] 04/06/04 11:17 AM >>>
What happens when i do conn.close()? does it go back to the pool?
---
To: Struts Users Mailing List
> Cc:
> Subject: Re: Connection Pooling (How i use...)
>
>
>
> This your problem: closing the connection in your try block. Move it to a
> finally block..
>
> Marcelo Epstein wrote:
>
>
g getFoo() { return foo; }
public int getBar() { return bar;}
}
On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani"
<[EMAIL PROTECTED]> escreveu:
De: "Geeta Ramani" <[EMAIL PROTECTED]>
Data: Tue, 06 Apr 2004 12:50:29 -0400
Para: Struts Users Mailing List <[EMAIL PROTE
}
public String getFoo() { return foo; }
public int getBar() { return bar;}
}
On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani" <[EMAIL PROTECTED]> escreveu:
> De: "Geeta Ramani" <[EMAIL PROTECTED]>
> Data: Tue, 06 Apr 2004 12:50:29 -0400
> Para:
]
Sent: Tue 4/6/2004 10:20 PM
To: Struts Users Mailing List
Cc:
Subject: Re: Connection Pooling (How i use...)
This your problem: closing the connection in your try block. Move it to a
finally block..
Marcelo Epstein wrote
This your problem: closing the connection in your try block. Move it to a finally
block..
Marcelo Epstein wrote:
> I use the pool like this: (IS IT WRONG??) I think the connection is being closed..
>
> try {
> Context ctx = new InitialContext();
> if (ctx == null)
>
From: Marcelo Epstein [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 9:31 AM
To: Struts Users Mailing List
Subject: Re: Connection Pooling (How i use...)
I use the pool like this: (IS IT WRONG??) I think the connection is being
closed..
try {
Context ctx = new InitialContext();
Yes.
You really might want to consider a tool like iBATIS, but if you want to
do it yourself, here is the pattern:
Connection c = null;
try{
//get connection
try{
// get statement
try{
// get result set
// process result set
}finally{
// close result set if not
) and always in a
finally block.
Brian McClung
Senior Programmer
Belo Interactive
-Original Message-
From: Marcelo Epstein [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 11:31 AM
To: Struts Users Mailing List
Subject: Re: Connection Pooling (How i use...)
I use the pool like
http://proxool.sourceforge.net/
Avinash
-Original Message-
From: Marcelo Epstein [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 9:31 AM
To: Struts Users Mailing List
Subject: Re: Connection Pooling (How i use...)
I use the pool like this: (IS IT WRONG??) I think the connection is being
closed..
Yes, you need to put the conn.close() in a finally, something like this
Connection conn = null;
try {
...
conn = ds.getConnection();
...
} catch(Exception ex) {
} finally {
try {
conn.close();
} catch(Exception ex) {
System.err.println(ex);
}
}
In your way, if
I use the pool like this: (IS IT WRONG??) I think the connection is being closed..
try {
Context ctx = new InitialContext();
if (ctx == null)
throw new Exception("Boom - No Context");
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB");
22 matches
Mail list logo