File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes data mismatch error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "data mismatch error" Watch "data mismatch error" New topic
Author

data mismatch error

Roberto Favaro
Greenhorn

Joined: Mar 23, 2004
Posts: 24
Im writing a simple program to read and write from a database.I keep getting an error which I dont understand [Data mismatch in criteria section]....when I try to run the getProduct...Can anyone help.Thanx in advance



[ November 16, 2004: Message edited by: Bear Bibeault ]

[edited subject and added code tags - jeanne]
[ November 16, 2004: Message edited by: Jeanne Boyarsky ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
For future reference the topic title of Help does not help you but hurt you. Use a more detailed string of words!

Your error sounds like you are using the wrong type when you are passing parameters to your database. Using a double when it is looking for an integer or an integer when it is looking for a string.

Just an idea.

Eric
Bob Rocks
Greenhorn

Joined: Oct 21, 2004
Posts: 23
http://www.frontpagewebmaster.com/m-178811/tm.htm

Here is a case of a similar error
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Roberto,
In the query, you have id has a string:
String query = "SELECT * from Product WHERE id = '" + item + "'" ;

but in the result set it is an int:
int id = rs.getInt("id") ;

One of these needs to be changed.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
jQuery in Action, 2nd edition
 
subject: data mismatch error
 
Similar Threads
returning an int
Query
What is wrong?
Returning a 0 value error
Derby Embedded Database: errors in connection code