• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception is occurred. Please help.

 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a function written in UpdateDatabase.java class. When I am calling it. It is not returning the correct answer at all???
Here is the function



This function is called by following function call...



following is the database table:



if I use following statement the answer is returned:



after the call to database function it is always returning " ". It should return five1.
I do not know what is wrong with my code please help.
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry forgot to post exception.
Here is the exception on a function call.

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the table variable "@P2".
 
Tim Cooke
Sheriff
Pie
Posts: 3203
142
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
waqas imtiaz wrote:SELECT ? "
+ "FROM ? "
+ "WHERE ? = ? ";

In a PreparedStatement you can only use ? as placeholders for data items in the "where" clause of your SQL statement. You cannot use ? as placeholders for column or table names.

You'll need to include the column and table name directly in your statement, for example:
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See I got it thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic