Bradley Bradley - 1 year ago 86
Java Question

MySQL inserting data while only knowing 1 column name

I am wanting to insert some data into a MySQL table, these are the columns:

uuid | id_1 | id_41

the "id_1" and "id_41" could be anything, all I know is the primary key (uuid) and I am wanting to be able to insert into the table while only knowing the uuid column value as I am doing this so far:

PreparedStatement newPlayer = "INSERT INTO `test` values(?);";
newPlayer.setString(1, event.getPlayer().getUniqueId().toString());

But when I test it, it doesn't add to the table and does not produce any errors. I also know that all of the other values have a default value of 0

mmm mmm
Answer Source

If you want to add a row without all columns included, you need to specify the column's name

INSERT INTO `test` (`uuid`) values(?);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download