aspose file tools*
The moose likes JDBC and the fly likes SQLException: Data truncated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException: Data truncated" Watch "SQLException: Data truncated" New topic
Author

SQLException: Data truncated

joseph okon
Ranch Hand

Joined: Dec 07, 2004
Posts: 63
hi
I am trying to insert double data type into my database but it is giving me an exception which goes like this

this my java code

this is my database disription

can any member of the ranch tell me what is happening cause am loss , i can think of anything again
thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
The code doesn't actually use any of the parameters you're passing to it - it's passing along string literals. Instead of

... values('bankType',chequeNum, ...

you need something like

... values('"+bankType+"', "+chequeNum+", ...

It would be much better use PreparedStatement for this - that way you avoid the string concatenation, and also don't need to worry about quotes around string arguments.


Ping & DNS - updated with new look and Ping home screen widget
joseph okon
Ranch Hand

Joined: Dec 07, 2004
Posts: 63
hi Dittmer
sorry i don't really understand what you mean.
please can you expanciate it for me maybe with an illustration code
thanks
joe

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
In that case it's probably best to start by working through the JDBC tutorial (http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/jdbc/index.html), and at first to get much simpler tables to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException: Data truncated
 
Similar Threads
mysql connection using eclipse (ubuntu)
Mysql driver fails on connection
mysql..connectivity
MySQLSyntaxErrorException
Using PreparedStatement