Subject Re: [Firebird-Java] couldn't start local transaction...
Author Mandip S. Sangha
Hi David

The code being executed for every query is:

Class.forName (driverClass).newInstance();
connection = DriverManager.getConnection (url,properties);
statement = connection.createStatement();
resultSet = statement.executeQuery(sqlString);

resultSet = null;

statement = null;

connection = null;

I've got a sys.out at point (1) that checks:
a) Whether the connection is null.
b) Whether the connection is closed.
BOTH RETURN FALSE even when the error in question is thrown!

When the error is thrown the code fails at point (2), as far as I can
see(from the above checks) the connection and statement are fine up to
this point

Therefore, am I correct in assuming that the error cannot be thrown
because we "can't get a connection" or the "connection died and the
driver didn't notice".

If not please can you tell me how to check the connection really is
valid and is open.

Otherwise that leaves the possibility of "the server dying", if I've
understood correctly what you mean by this then this is not an issue
since there has never been an instance where the error has actually
crashed/stopped/shutdown the database server. Also the database server
that I connect to is running locally eliminating any problems that could
be caused by sending things over the wire.

This leads me back to the error:

[GDS_Impl,DEBUG] Got socket
[GDS_Impl,DEBUG] mandip
[GDS_Impl,DEBUG] op_connect
[GDS_Impl,DEBUG] sent
[GDS_Impl,DEBUG] op_accept
[FBManagedConnectionFactory,ERROR] GDS Exception in getDbHandle
org.firebirdsql.gds.GDSException: unable to complete network request to host
at org.firebirdsql.jgds.GDS_Impl.connect(

Looking at the connect method in the GDS_Impl class we see:

db.out.writeInt(3); // ptype_batch_send
if (log.isDebugEnabled()) {log.debug("sent");}
if (log.isDebugEnabled()) {log.debug("op_accept ");}
if (readOperation(db) == op_accept) {; // Protocol version number; // Architecture for protocol; // Minimum type
if (log.isDebugEnabled()) {log.debug("received");}
else {
if (log.isDebugEnabled()) {log.debug("not received");}
throw new GDSException(isc_connect_reject);
} catch (IOException ex) {
throw new GDSException(isc_network_error);

Everthing executes fine up to point (1) as reflected by the log message,
but after this things become unclear, can we determine at exactly what
point the exception is thrown?

Again your comments/suggestions would be greatly appreciated. :-)


David Jencks wrote:

> Either you can't get a connection due to misconfiguration or the server
> dying or a connection died and the driver didn't notice. Due to adapting
> firebird to xa semantics the driver doesn't actually make a connection
> until it knows what transaction you are working in.
> Do some of your tests succeed?
> Does some test before the one that fails in this way do something that
> might break the connection?
> If you are using the built in pooling, try turning it off and see what
> happens: if you aren't, you might try turning it on;-)
> david jencks