My query executed properly, my problem with numRowsAffected() always return -1, is there a way to get number of rows has been returned.
My query executed properly, my problem with numRowsAffected() always return -1, is there a way to get number of rows has been returned.
Yes, read the docs of the methods you are using. Besides, if you are interested in the number of rows, then ask the database about the number of rows and not about rows themselves.
sql Code:
SELECT COUNT(*) FROM user WHERE user='root'To copy to clipboard, switch view to plain text mode
By the way, are you sure the query you posted is really valid? You have a table called "user" that has a column that's also called "user"?
I found size method return number of rows founded.
Yes, its valid, this is mysql database that chiped with MySQL server, you can give a table and a column some name.By the way, are you sure the query you posted is really valid? You have a table called "user" that has a column that's also called "user"?
If you are only interested in the number of rows matching the criteria then don't use size() but rather COUNT(*). Then you'll always get one row with the number of entries instead of getting multiple rows which is less efficient.
Bookmarks