Subject Fwd: jaybird prepared statement
Author Roman Rokytskyy
Below is my reply that I have sent you privately.


> I would like to ask you if the java driver jaybird
> driver has a toString method on prepared
> statement which will give as result the sql

No, it does not.

> The mysql JConnector has one so i wonered if is
> difficult to do this on jaybird also.

Why do you need it? What is the purpose of this feature in mySQL? Can it be
that mySQL instead of executing the statement with parameters executes the
string where param marks are replaced with values? You should know that
Firebird works differently.

> Can i do this for my personal use.

Sure, but then you have problem to sync your changes with each new release.
So, better to add it to the main CVS tree. This will not go into JayBird
2.0, but may be part of JayBird 2.1.

> How?

See the and

First of all, you have to store the SQL statement passed into the
constructor (currently we send it directly to server and store only the
statement handle). Then you have to loop through all fields (not a hard
part) and replace '?' with string values. For this you really need good SQL
syntax parser, since, for example the INSERT INTO table_a VALUES(?, 'is it
good?', ?) should be converted into INSERT INTO table_a VALUES(1, 'is it
good?', 2), but not into INSERT INTO table_a VALUES(1, 'is it good2', ?). I
mean that you have to handle correctly literals at least.

So, the task is not easy. Also beware, that after adding this code to the
main CVS you are responsible for it and you have to support people in the
Firebird-Java group. :)