“column not allowed here” error in INSERT statement

前端 未结 8 2425
心在旅途
心在旅途 2020-12-05 17:39

I created this table called LOCATION by doing this:

CREATE TABLE LOCATION(
POSTCODE VARCHAR(10) PRIMARY KEY,
STREET_NAME VARCHAR(20),
CITY VARCHAR(20));
         


        
8条回答
  •  自闭症患者
    2020-12-05 18:18

    Scanner sc = new Scanner(System.in); 
    String name = sc.nextLine();
    String surname = sc.nextLine();
    Statement statement = connection.createStatement();
    String query = "INSERT INTO STUDENT VALUES("+'"name"'+","+'"surname"'+")";
    statement.executeQuery();
    

    Do not miss to add '"----"' when concat the string.

提交回复
热议问题