• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement not working properly

 
Bharvi Dixit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am not able to find out that why the second pst=con.prepareStatement(String arg) is not working. i have tried other queries too in place of that argument but they are also not getting executed.. And when i remove them.. the next statements are executed.. Why this weired result??? Please help me out..


Thanks in advance,
Bharvi.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "not working" mean? Do you get an exception?

Your statement has four parameters (the question marks), but you set only three of them. That might be the problem.

Edited to add: you don't enumerate the columns you're inserting into. It is therefore possible that the columns are in different order in the database than you anticipate. Always specify the column lists in select and insert statements.
 
Bharvi Dixit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Martin Vajsar for the reply.
I have tried everything, from specifying column names to setting 3 placeholders for 3 parameters.
I had put an extra placeholder so that it generates an exception. But it didn't.
The only problem is pst.executeStatement(); is not executing at all. Neither i am getting any exception.
Program just breaks down without any exception or warning.

I have just found that there is a constraint in my tables, which might be the reason for this. But it must generate an exception.

Thank you so much for the reply.


Bharvi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic