0

Im getting INVALID COLUMN INDEX when trying to insert data in table.

This is my DAO. Not sure why there is invalid column index.

    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();  

           }

Is there anything i missed??? Thank you in advance! :)

1
  • Learn about prepared statements.show your table definition Commented Feb 5, 2016 at 7:49

1 Answer 1

2

You need to write your query like this:

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

The question marks are placeholders for fixed values that you must set before executing an SQL statement.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.