aspose file tools
The moose likes JDBC and the fly likes SQLException: Data truncated Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 35252
    
    7
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.


Android appsImageJ pluginsJava web charts
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: 35252
    
    7
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
Using PreparedStatement
Mysql driver fails on connection
MySQLSyntaxErrorException
mysql connection using eclipse (ubuntu)
mysql..connectivity