Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法更新我的数据库_Java_Database_Textfield - Fatal编程技术网

Java 无法更新我的数据库

Java 无法更新我的数据库,java,database,textfield,Java,Database,Textfield,我无法使用我的文本字段中的值更新我的数据库。我没有异常错误,但没有任何异常 private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { row = table.getSelectedRow(); int column = table.getColumnCount(); try { Conn(); System.out.print(table.getValueA

我无法使用我的文本字段中的值更新我的数据库。我没有异常错误,但没有任何异常

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {
    row = table.getSelectedRow();
    int column = table.getColumnCount();

    try {
        Conn();
        System.out.print(table.getValueAt(row,0));
        pStmt = conn.prepareStatement("update customer_tbl set LName = '" + txtLname.getText() + "', FName= '" 
            + txtFname.getText() + "', Address = '" + txtAddress.getText() + "', ContactNumber = '"+txtContact.getText() 
            + "', Age = '" + txtAge+"' WHERE Name_ID = '" + table.getValueAt(row,0) + "'");

        //  st = conn.createStatement();
        // rs = st.executeQuery("UPDATE customer_tbl SET Fname = '"+txtFname.getText()+"' Lname= '"+txtLname.getText()+"', Age = '"+txtAge.getText()+"', Address = '"+txtAddress.getText()+"', ContactNumber = '"+txtContact+"' WHERE Customer_id = '"+ table.getValueAt(row,0)+"'");
        pStmt.executeUpdate();

        JOptionPane.showMessageDialog(null,"Update success !");

        //FillList();
    }

对不起,我知道答案了。我正在将
Age=txtAge
设置为不
txtAge.getText()

您的
catch(…){…}
块中有什么?出现异常sir com.mysql.jdbc.MysqlDataTruncation:数据截断:数据对于第1行的“Age”列太长???在你的问题中,尽管你说,
“我没有异常错误…”
,所以你上面的陈述,
“有异常”
让我很困惑。是哪一个?你最近删除了它,但没有对此负责,也没有让我们知道哪里出了问题,然后你问了这个问题,这没有意义,是“重新异常”还是“无异常”(是因为你没有捕捉到异常?)。。。。请查看上的部分,了解如何改进您未来的问题,以便这些问题能够得到回答并有意义。