MySql数据在第1行被截断为列'advance' [英] MySql Data truncated for column 'advance' at row 1

查看:709
本文介绍了MySql数据在第1行被截断为列'advance'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用了txtAdvance的关键事件。

In my project I used txtAdvance 's key event.

    double gtotal = Double.parseDouble(txtGtotal.getText());
    double ad = Double.parseDouble(txtAdvance.getText());
    double due = gtotal - ad;
    txtDue.setText(String.valueOf(due));

最后一行运行后,我添加一个保存按钮来保存这些数据。以下是查询。

And after last line run, I add a save button to save those data. Given below is that query.

    public void saveInvoice(JTextField txtgtotal, JTextField txtAdvance, JTextField txtDue, JTextField txtInID) {

    try {
        db.putData("INSERT INTO indetails(inid, gtotal, advance, due) VALUES( '" + txtInID.getText() + "' ,'" + txtgtotal.getText() + "' , '" + txtAdvance.getText() + " ' " + " , '" + txtDue.getText() + "') ");
        JOptionPane.showMessageDialog(null, txtAdvance.getText());

        JOptionPane.showMessageDialog(null, "Invoice details saved");
    } 
    catch (Exception e) {
        JOptionPane.showMessageDialog(null, this.getClass().getName() + " first " + e);
    }
}

我将MySql数据截断为列'advance '在第1行。 advance的数据类型为Double。但是我找不到一个放置长度的方法。号
(作为示例

列名称:iid,数据类型:Int(18){主键}

列名称:inid,数据类型:Int(18)

列名:gtotal,数据类型:Double

列名称:advance,数据类型:Double

列名称:到期,数据类型:Double

I'm having MySql Data truncated for column 'advance' at row 1 . advance's data type is Double. But I can't find a way to put length.
(As an example
Column Name : iid, Data type : Int(18) {Primary key}
Column Name : inid, Data type : Int(18)
Column Name : gtotal, Data type : Double
Column Name : advance, Data type : Double
Column Name : due, Data type : Double
)

我正在使用MySQL查询浏览器。问题是当我添加0值到txtAdvance我有这个错误。

I'm using MySQL query browser . Question is when I'm adding 0 value to txtAdvance I'm having this error.

推荐答案

如果您尝试保存的数据具有小数点,则将数据类型更改为 10 10 10 表示数字, 3 表示小数位数。

If the data you are trying to save have decimal points then change the datatype for advance as double with length 10,3 where 10 denotes number of digits and 3 denotes the number of decimal digits.

使用此查询

db.putData("INSERT INTO indetails(inid, gtotal, advance, due) VALUES(" + txtInID.getText() + "," + txtgtotal.getText() + "," + txtAdvance.getText() + "," + txtDue.getText()+")");

这篇关于MySql数据在第1行被截断为列'advance'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆