Subject | Re: Reconnect Parameter |
---|---|
Author | Torsten Welches |
Post date | 2000-09-03T17:38:21Z |
Hi Edward,
I tried to reproduce the disconnects - no luck. I was able to have an
idle connection for long periods of time (more than 9 hours) without
getting disconnected.
Here's what I did:
static public void main (String args[]) {
interbase.interclient.DataSource dataSource = new
interbase.interclient.DataSource();
dataSource.setDatabaseName("c:/program
files/Borland/InterBase/examples/database/employee.gdb");
java.sql.Connection c = null;
try {
c = dataSource.getConnection("sysdba","masterkey");
} catch (java.sql.SQLException connectionFailure) {
System.out.println("connection failed: " + connectionFailure);
return;
}
int timeout = 1000; //let's start with one second
while (true) { //forever until we hit an exception or kill the vm
//first let's wait...
try {
Thread.sleep(timeout);
System.out.println("connection was idle for " + timeout/1000
+ " seconds");
} catch (Exception uhoh) {
System.out.println("failed to wait?!: " + uhoh);
return;
}
timeout *= 2; //next time we try it double the time;
try {
java.sql.Statement stmt = null;
java.sql.ResultSet results = null;
try {//do a dummy db access
stmt = c.createStatement();
results = stmt.executeQuery("Select count(*) from JOB");
results.next();
} finally {
if (results != null) results.close();
if (stmt != null) stmt.close();
}
} catch (java.sql.SQLException e) {
System.out.println("sql exception: " + e.getMessage());
if (c != null) {
try { c.close(); } catch (java.sql.SQLException ignore) {}
}
return;
}
}
}
After "connection was idle for 32768 seconds" I gave up...
Maybe it's platform dependant? I'm under NT, which OS do you use?
Regards,
Torsten
I tried to reproduce the disconnects - no luck. I was able to have an
idle connection for long periods of time (more than 9 hours) without
getting disconnected.
Here's what I did:
static public void main (String args[]) {
interbase.interclient.DataSource dataSource = new
interbase.interclient.DataSource();
dataSource.setDatabaseName("c:/program
files/Borland/InterBase/examples/database/employee.gdb");
java.sql.Connection c = null;
try {
c = dataSource.getConnection("sysdba","masterkey");
} catch (java.sql.SQLException connectionFailure) {
System.out.println("connection failed: " + connectionFailure);
return;
}
int timeout = 1000; //let's start with one second
while (true) { //forever until we hit an exception or kill the vm
//first let's wait...
try {
Thread.sleep(timeout);
System.out.println("connection was idle for " + timeout/1000
+ " seconds");
} catch (Exception uhoh) {
System.out.println("failed to wait?!: " + uhoh);
return;
}
timeout *= 2; //next time we try it double the time;
try {
java.sql.Statement stmt = null;
java.sql.ResultSet results = null;
try {//do a dummy db access
stmt = c.createStatement();
results = stmt.executeQuery("Select count(*) from JOB");
results.next();
} finally {
if (results != null) results.close();
if (stmt != null) stmt.close();
}
} catch (java.sql.SQLException e) {
System.out.println("sql exception: " + e.getMessage());
if (c != null) {
try { c.close(); } catch (java.sql.SQLException ignore) {}
}
return;
}
}
}
After "connection was idle for 32768 seconds" I gave up...
Maybe it's platform dependant? I'm under NT, which OS do you use?
Regards,
Torsten
--- In IB-Java@egroups.com, Mark O'Donohue <mark.odonohue@l...> wrote:
> >
>
> Hi Edward,
>
> > Date: Thu, 31 Aug 2000 09:46:06 -0500
> > From: "Edward Flick" <eddy@c...>
> >
> > Hi Mark,
> > After a connection has been idle for a certain amount of time
Interbase
> > disconnects without InterClient being notified.
>
> I've added this to our bug list, I suspect that we'll discuss it
when Torsten
> gets back.
>
> If you have any more you want to put in anyone can put them in at ,
> http://sourceforge.net/bugs/?group_id=9028 .
>
> Or send them here, and I'll put them in for you.
>
> Cheers
>
> Mark