Inserting records into a MySQL table using Java

后端 未结 4 2104
北海茫月
北海茫月 2021-02-13 14:45

I created a database with one table in MySQL:

CREATE DATABASE iac_enrollment_system;

USE iac_enrollment_system;

CREATE TABLE course(
    course_code CHAR(7),
          


        
4条回答
  •  抹茶落季
    2021-02-13 15:17

    this can also be done like this if you don't want to use prepared statements.

    String sql = "INSERT INTO course(course_code,course_desc,course_chair)"+"VALUES('"+course_code+"','"+course_desc+"','"+course_chair+"');"
    

    Why it didnt insert value is because you were not providing values, but you were providing names of variables that you have used.

提交回复
热议问题