krummas / DrizzleJDBC

A BSD licensed JDBC driver for Drizzle and MySQL
BSD 3-Clause "New" or "Revised" License
31 stars 22 forks source link

Some rows of informations returns value '0' in drizzle-jdbc1.2 #12

Closed Haseena closed 11 years ago

Haseena commented 11 years ago

I have a java application which I use MySQL database as back-end and eclipse as front end. My Db contains more than one tables. From my java application Iam trying to connect MySQL by using MySQL-connector-java-5.1.12 as earlier. I have a check box in the application, when checked/unchecked, some datas fetched from the database based on my select query (query contains join statement of more than two tables). The select query is different in chech/uncheck. It works properly and got result what I expect.

My problem is now I change the connector of mysql to drizzle-jdbc1.2, select query doesn't work properly based on the query I send to the DB. Initially the check box is cleared, this time result is perfect. When I check it, my expectation is some additional rows are coming, but the result contains 0's only instead of additional rows. Why?

Note : The same queries are succesfully returns the correct result in the console on the in MySQLQueryBrowser. So I think this issue is related to the drizzle-jdbc itself only.

krummas commented 11 years ago

could you provide a small code example so i can reproduce it?

what methods do you use on the JDBC driver and how does the data look in the database?

Haseena commented 11 years ago

See this link for sample code : https://gist.github.com/85d40586c4e7db466178

krummas commented 11 years ago

hmm cant find anything strange

could you provide a database snippet as well? then i could try to reproduce

krummas commented 11 years ago

and i guess this part is not correct?

ResultSet resultSet = statement.executeQuery(query);                        

 while (!result.isClosed() && result.next()) {

should be while(!resultSet ...) right? (guessing it is just a prepare-for-github-bug?)

Haseena commented 11 years ago

Oh! Sorry L Its my mistake when writing the snippet. Actual code in my java application is correct. That is :

ResultSet result = statement.executeQuery(query);

while (!result.isClosed() && result.next()) {

Its corrected in https://gist.github.com/85d40586c4e7db466178

Actual problem present with drizzle-jdbc only

krummas commented 11 years ago

ok, what values are wrong when using drizzle-jdbc?

Haseena commented 11 years ago

First query returns the result what I expect. My expectation of second query is it returns the result which contain same as of first resultset and additional some rows in the table4. But here i got no additional rows from the table4, instead of actual result, it contains all fields are zero. I don't know why this happening....

krummas commented 11 years ago

hmm could you try not reusing the same statement for the second query?

ie, add a statement = connection.createStatement(...) before executing the second query

Haseena commented 11 years ago

Already used. In my application connection function and executeQuery() is in another function.

krummas commented 11 years ago

ok, then i really dont know, i would need some actual data to rerun it on

Haseena commented 11 years ago

Hi krummas,

Sorry for the delay, please see the actual data that can be attached in the following link (created as sampledb.sql file)

https://gist.github.com/8a24948eea41cdafbdc9

krummas commented 11 years ago

Hi

i tried out your data with this code (i just tried to make it work without the Packet class etc): https://gist.github.com/4120613

and i do seem to get data for the Table4 stuff, could you check and let me know where it fails for you (or if i translated you example badly)

krummas commented 11 years ago

btw, could it be a threading issue? do you have multiple threads reading the result?

Haseena commented 11 years ago

A glad news!!! now the issue is fixed.... Thanks a lot for ur valuable help. Iam comparing the sample code and my actual code, there is no difference seen. Further verification, I found the actual issue, that is in calling the Table4.ID field.

long Id = result.getLong(ITable4.ID);

This line is changed to

long Id = result.getLong(ITable4.TABLE_NAME + "." + ITable4.ID);

Now its working....

krummas commented 11 years ago

cool, great!