Skip to content
Advertisement

JDBC, Prepared Statement getInt() returns 0

In my DB every question has a valid questionID (primary Key) and categoryID (foreign Key to category table). The problem is: in the Result Set for every question both IDs are 0 instead of what’s written in the DB. All other arguments are filled out correctly.


Edit 1

Here is the original code (in the post I changed the variables from German to English):

The creation of my SQL table:

Advertisement

Answer

Most likely, there is a problem with the constructor. You might have not set questionID and categoryID in the constructor and therefore you are getting the default value of int as 0.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement