Re: [Sqlrelay-discussion] ping() in Java
Brought to you by:
mused
|
From: David M. <dav...@fi...> - 2005-11-30 02:51:44
|
ping() will return true or false depending on whether SQL Relay is
connected to the backend database or not. Ie. the client will connect
to SQL Relay, check the status of the database and disconnect. But, if
the database is down and you run a query, the client will remain
connected to the SQL Relay server until the server comes back up, at
which point the query will be run against the now-up database.
This is intentional, the idea is that if the network hiccups or a
load-balanced database server goes down, the SQL Relay server will
recover and, aside from a pause, it will appear as if nothing happened
to the clients.
David Muse
dav...@fi...
On Wed, 2005-11-23 at 09:04 +0100, Maciej Wisniowski wrote:
> Hi!
>
> I have a simple web service written in java, that gets data from
> database using SQLRelay. The problem is with ping command.
>
> This is part of my code:
>
> import com.firstworks.sqlrelay.SQLRConnection;
> import com.firstworks.sqlrelay.SQLRCursor;
>
> if (conn.ping()){
> ...do something...
> }
>
> The database I'm connecting to is backuped every night and swithed down
> for a while and possibly this causes problem. Every morning I'm receiving
> 'false' from ping() command, but... when I'm trying to send query even
> when ping
> returns 'false' it executes correctly... I did something like this:
>
> if (conn.ping()){
> ...do something...
> }
> else{
> SQLRCursor cur=new SQLRCursor(conn);
> cur.getNullsAsNulls();
>
> String query = "SELECT * from table";
> cur.sendQuery(query);
> System.out.println("ping false. rowCount:"+cur.rowCount());
> }
>
>
> and rowCount() returns 1 for my select, so... connection works!
> Strangely after doing this query and starting my program again ping
> returns 'true'... till next morning.
>
> I think it's possibly a bug with ping() in java code...?
>
|