• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

exception is occurred. Please help.

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See I got it thanks.
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic