0

I have a fragment of code in Java which inserts data into my database.

I was advised to put AUTO_INCREMENT and give each row a unique number.

But it now gives me an error:

java.sql.SQLException: Incorrect integer value: 'DEFAULT' for column 'usersID' at row 1

I assume this is because it's casting the AUTO_INCREMENT value into a string?

How do I get around this as it's not my java program that creates the unique number, but the database itself.

pst.setString(1, "DEFAULT");

String query_to_update = "INSERT INTO `evidence_db`.`mcases` ("
                        + "`PID`,"
                        + "`Name`) "
                        + "VALUES (?,?);";
4

1 回答 1

1
pst.setInt(1, 0);

上面是我需要的线。感谢所有试图提供帮助的人。

于 2012-12-14T18:43:43.223 回答