Subject | Fwd: jaybird prepared statement |
---|---|
Author | Roman Rokytskyy |
Post date | 2005-07-15T08:00:45Z |
Below is my reply that I have sent you privately.
-----------------------------
Hi,
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.
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.
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. :)
Roman
-----------------------------
Hi,
> I would like to ask you if the java driver jaybirdNo, it does not.
> driver has a toString method on prepared
> statement which will give as result the sql
> The mysql JConnector has one so i wonered if isWhy do you need it? What is the purpose of this feature in mySQL? Can it be
> difficult to do this on jaybird also.
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 AbstractPreparedStatement.java and AbstractStatement.java
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. :)
Roman