错误消息:java.sql.SQLException:列索引无效

错误消息:java.sql.SQLException:列索引无效,java,jdbc,prepared-statement,Java,Jdbc,Prepared Statement,尝试在表中插入数据时,我得到的列索引无效 这是我的刀。不确定为什么有无效的列索引 try{ currentCon = JavaConnectionDB.getConnection(); PreparedStatement ps=currentCon.prepareStatement("insert into lecturer (lecturerID,lecturerFullname,lecturerPassword) values'"

尝试在表中插入数据时,我得到的列索引无效

这是我的刀。不确定为什么有无效的列索引

    try{  
            currentCon = JavaConnectionDB.getConnection();
            PreparedStatement ps=currentCon.prepareStatement("insert into lecturer (lecturerID,lecturerFullname,lecturerPassword) values'"
                    + lecturerID + "','" + lecturerFullname + "','" + lecturerPassword +"'");  
            ps.setString(1,Lbean.getLecturerID());  
            ps.setString(2,Lbean.getLecturerFullname());  
            ps.setString(3,Lbean.getLecturerPassword());  
            ps.executeUpdate();  

           }

有什么我错过的吗???先谢谢你!:)

您需要这样编写查询:

  insert into lecturer (lecturerID,lecturerFullname,lecturerPassword) values(? , ? , ?);

问号是在执行SQL语句之前必须设置的固定值的占位符。

您需要这样编写查询:

  insert into lecturer (lecturerID,lecturerFullname,lecturerPassword) values(? , ? , ?);

问号是在执行SQL语句之前必须设置的固定值的占位符。

了解准备好的语句。显示表定义了解准备好的语句。显示表定义