Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Connection.isClosed() does not return value as axpected

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-05-19 21:07:31.0Z
Michiel Veen Posted on 1997-05-07 09:19:42.0Z
Message-ID: <3370492E.6A41@tcf.nl>
Date: Wed, 07 May 1997 11:19:42 +0200
From: Michiel Veen <michiel@tcf.nl>
Reply-To: michiel@tcf.nl
Organization: The Connection Factory
X-Mailer: Mozilla 3.01 (WinNT; I)
MIME-Version: 1.0
Subject: Connection.isClosed() does not return value as axpected
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 33
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:866
Article PK: 252620

Hi all,

At the moment we are testing our Servlet which accesses a Sybase
database using JDBC. In the servlet we are maintaining an open
connection with the database. Clients can use this open connection
so they don't have the overhead of opening and closing the
connection.

Before the Servlet executes a query it checks if the connection is
open, if it isn't, it reopens the connection and executes the query
(see code below).

However if we shut down the database the Connection.isClosed()
returns false, indicating that the connection is still open....

Is this a bug?

We did some more testing and the isClossed() call always returns
false after the initial opening of the database...

Is there an other way of checking if the connection is open and/or
if the database is offline?

Regards Michiel


-------------- code for checkin the connection --------------

private void checkConnection() throws TcfException {

boolean isClosed = false;
try {
isClosed = connection.isClosed() ;
}
catch (SQLException ex) {
isClosed = true;
}

if (isClosed) {
buildConnection(); // will trow exception if database is offline
}
}


--

#-- michiel@tcf.nl
#-- The Connection Factory b.v.
#-- http://www.tcf.nl


Lance Andersen Posted on 1997-05-19 21:07:31.0Z
Message-ID: <3380C113.18CB@sybase.com>
Date: Mon, 19 May 1997 17:07:31 -0400
From: Lance Andersen <lancea@sybase.com>
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m)
MIME-Version: 1.0
To: michiel@tcf.nl
Subject: Re: Connection.isClosed() does not return value as axpected
References: <3370492E.6A41@tcf.nl>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 50
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:819
Article PK: 252571

currently it appears that Connection.isClosed() only returns
true if Connection.close() is invoked.

I am looking into to this further.


-Lance

Michiel Veen wrote:
>
> Hi all,
>
> At the moment we are testing our Servlet which accesses a Sybase
> database using JDBC. In the servlet we are maintaining an open
> connection with the database. Clients can use this open connection
> so they don't have the overhead of opening and closing the
> connection.
>
> Before the Servlet executes a query it checks if the connection is
> open, if it isn't, it reopens the connection and executes the query
> (see code below).
>
> However if we shut down the database the Connection.isClosed()
> returns false, indicating that the connection is still open....
>
> Is this a bug?
>
> We did some more testing and the isClossed() call always returns
> false after the initial opening of the database...
>
> Is there an other way of checking if the connection is open and/or
> if the database is offline?
>
> Regards Michiel
>
> -------------- code for checkin the connection --------------
>
> private void checkConnection() throws TcfException {
>
> boolean isClosed = false;
> try {
> isClosed = connection.isClosed() ;
> }
> catch (SQLException ex) {
> isClosed = true;
> }
>
> if (isClosed) {
> buildConnection(); // will trow exception if database is offline
> }
> }
>
> --
>
> #-- michiel@tcf.nl
> #-- The Connection Factory b.v.
> #-- http://www.tcf.nl

--
===============================================================================
Lance J. Andersen Email: lancea@sybase.com
Sybase Technical Support Phone:(617) 564-6336
77 South Bedford Street Fax: (617) 564-6148
Burlington, MA 01803

The Dark Knight Returns!!! Let's Go Penguins!!!
===============================================================================