I'm making a Java program that generates random data and populates a PostgreSQL Database. I'm at the beginning of my program and the following code is actually the part adding a row (not generated randomly) to the table public.bank_card_people . The columns of the table are first-name, last-name and card-number. The connection with database is effective as I achieve to print rows from the table.
public static void main(String[] args) {
try{
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Benerator","postgres","newPassword");
String SQL = "insert into public.bank_card_people (first-name, last-name, card-number) VALUES (?,?,?)";
PreparedStatement stmt2 = con.prepareStatement(SQL);
stmt2.setString(1, "ra");
stmt2.setString(2, "ra");
stmt2.setString(3, "ra");
stmt2.executeQuery();
I ran the program and had the error ERROR: syntax error at or near "-"Position: 43
I will keep you updated if I find a solution!