This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

prepared statement -select- and?

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to write a select query but i get error
(the error is mentione the and section in select query)
String select = "Select *"+" from tseller where name=? and manfac=?";
pstmt = con.prepareStatement(select);
pstmt.setString(1,Name);
pstmt.setString(2,Manfac);
ResultSet rows = pstmt.executeQuery(select);
do you know what is wrong?
thnx,
Sahar.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


do you know what is wrong?



Certainly not , unless you show us the error.
 
sahar sa
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure! this is the error:

SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? and manfac=?' at line 1
SQLState: 42000
VendorError: 1064
do you have any idea whats wrong?
thnx
sahar
 
Marshal
Posts: 67390
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difficult to be sure, but you appear to be passing the ? directly to MySQL. Are you passing that select instruction via JDBC or at a command-line?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



why do you need pass query to preparedstatement. try pstmt.executeQuery().
 
Bartender
Posts: 2657
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Balu Sadhasivam wrote:


why do you need pass query to preparedstatement. try pstmt.executeQuery().

That is a good catch. Looked over it.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!