From: | "Iain" <iain(at)mst(dot)co(dot)jp> |
---|---|
To: | <EAdelaRosa(at)smart(dot)com(dot)ph> |
Cc: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: closing statements when connection is closed |
Date: | 2004-02-10 07:58:54 |
Message-ID: | 003e01c3efab$ba90be40$7201a8c0@mst1x5r347kymb |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi Eduado,
Thanks for that, I'll be sure to check it out as soon as I can.
I'm using both linux and windows. I wish I could have a windows-less life
but I can't. Windows is ubiquitous.
regards
iain
----- Original Message -----
From: "Eduardo A. dela Rosa" <EAdelaRosa(at)smart(dot)com(dot)ph>
To: "Iain" <iain(at)mst(dot)co(dot)jp>
Sent: Tuesday, February 10, 2004 3:33 PM
Subject: Re: [JDBC] closing statements when connection is closed
> Okay, are you using Linux? Please don't switch to Windows! Stay
> with Linux :)
>
> I know now what you're problem is...
>
> You may have declared and initialized your connection object
> within a try/catch block, like this:
>
> private void sqlMethodSQL(){
>
> try{
> Connection con = ds.getConnection();
> ..
> }catch(SQLException sqle){
> try{
> con.close(); // This will result to a compile time error!
> ...
> }catch(SQLException sqle2){
> // never mind
> }
> }
>
> }
>
>
> Rather, try this one:
> ---------------------
>
> private void sqlMethodSQL(){
>
> Connection con = null;
>
> try{
> con = ds.getConnection();
> ..
> }catch(SQLException sqle){
> try{
> con.close();
> ...
> }catch(SQLException sqle2){
> // never mind
> }
> }
>
> }
>
> NOTE: If you are trying to close Statement or ResultSet, too,
> declare and initialize them outside and before the try/catch
> block.
>
> HTH :)
>
> On Tue, 2004-02-10 at 13:51, Iain wrote:
> > (I forgot to CC the list)
> > ----- Original Message -----
> > From: "Iain" <iain(at)mst(dot)co(dot)jp>
> > To: <EAdelaRosa(at)smart(dot)com(dot)ph>
> > Sent: Tuesday, February 10, 2004 2:49 PM
> > Subject: Re: [JDBC] closing statements when connection is closed
> >
> >
> > > > Could you post the exact compile time error for this particular
block?
> > > > You may be forgetting to enclose the close() method further
> > > > in a try-catch block :)
> > >
> > > The message was some complaint that the variable might not be
initialized.
> > >
> > > It created the situation where I couldn't close the statement if there
was
> > > an exception. I think I understand what you mean though, I need to put
the
> > > close() statement in a second try block after the one the caused the
> > error?
> > > Or just use a try close block nested in the first catch block. I'll
give
> > it
> > > a try.
> > >
> > > I'll dig up the code and the message for you. I'll have to switch my
> > windows
> > > setting back to English though - unless you can read Japanese (I can't
but
> > I
> > > still have to work with it - if I switch my windows language setting
to
> > > English then my other M$ apps don't work correctly :-( )
> > >
> > > Thanks
> > > iain
> > >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if
your
> > joining column's datatypes do not match
> --
> EDUARDO A. DELA ROSA
> MCOM/3792
>
> http://www.smart.com.ph
>
> contumacious \kahn-too-MAY-shuss\ adjective
>
> o stubbornly disobedient
> o rebellious
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2004-02-10 12:25:15 | Re: closing statements when connection is closed |
Previous Message | Iain | 2004-02-10 05:51:01 | Re: closing statements when connection is closed |