3

I am trying to use to insert into the table but got the exception that array index out of bounds ?

Please give me the idea how to do that and where is I am making mistake? I have tried many conversion but doesn't get succeeded.

Following is the code

 Object[]param={ID,name,Fathername,Address,Mob,Gender,Qualification};


 try{
 db=Display.getInstance().openOrCreate("students.db");

 db.execute("insert into clStudent values('?','?','?',?,'?','?','?')", (Object[]) param) ;
Yasir
  • 55
  • 3
  • 1
    you can refer [here](http://stackoverflow.com/questions/23202414/index-was-outside-the-bounds-of-the-array-microsoft-sqlserver-smo) the question already like yours! – heart hacker Oct 22 '16 at 07:50
  • Can you provide the stack trace of the exception from the console? – Shai Almog Oct 23 '16 at 01:32
  • java.lang.ArrayIndexOutOfBoundsException: 0 this is the exception i am getting when i try to use the getstackTrace () function it gives error that cannot find the symbol method.getstackTrac() @Shia Almog – Yasir Oct 24 '16 at 05:28
  • at org.sqlite.PrepStmt.batch(PrepStmt.java:272) at org.sqlite.PrepStmt.setNull(PrepStmt.java:403) at org.sqlite.PrepStmt.setNull(PrepStmt.java:396) at com.codename1.impl.javase.SEDatabase.execute(SEDatabase.java:125) at com.mycompany.myapp.DatabaseSQLite.addStudent(DatabaseSQLite.java:99) at com.mycompany.myapp.MyApplication.lambda$AddStudentForm$6(MyApplication.java:301) at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349) at com.codename1.ui.Button.fireActionEvent(Button.java:411) at com.codename1.ui.Button.released(Button.java:442) – Yasir Oct 24 '16 at 09:50
  • Thanks @YngveMoe it worked – Yasir Oct 25 '16 at 05:31
  • FYI you should upvote/accept the answer by clicking the checkbox next to it and the up arrow – Shai Almog Oct 27 '16 at 10:17

1 Answers1

2

You should drop the single quotes around the question marks in your query string.

Yngve Moe
  • 410
  • 2
  • 8