第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

“文本域驗(yàn)證工作不正常”

“文本域驗(yàn)證工作不正常”

驗(yàn)證部分出現(xiàn)問(wèn)題,沒(méi)有關(guān)于空字段的消息顯示。立即提供幫助private void addbtnActionPerformed(java.awt.event.ActionEvent evt) {    try{    Class.forName("com.mysql.cj.jdbc.Driver");    Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/dbfinance","root","1234");    String sql="insert into util(type_,due_date,month_,amount,units,status_) values(?,?,?,?,?,?)";    PreparedStatement pstm =con.prepareStatement(sql);    pstm.setString(1,electype.getSelectedItem().toString());    pstm.setString(2,date.getText().toString());    pstm.setString(3,jComboBox1.getSelectedItem().toString());    pstm.setDouble(4,Double.parseDouble(amount.getText()));    pstm.setString(5,unit.getText());    pstm.setString(6,status.getText());   pstm.executeUpdate();   JOptionPane.showMessageDialog(null, "success");   con.close();        }catch(Exception e){            JOptionPane.showMessageDialog(null,e);        }     if(amount.getText().isEmpty()||unit.getText().isEmpty()||status.getText().isEmpty()){            JOptionPane.showMessageDialog(null,"please enter data");           // errorname2.setText("fill this field");    }        }
查看完整描述

2 回答

?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

在驗(yàn)證之前,您不應(yīng)該將數(shù)據(jù)插入數(shù)據(jù)庫(kù)。僅當(dāng)數(shù)據(jù)不為空時(shí)才插入數(shù)據(jù)。至于檢查數(shù)據(jù)是否為空,最好修剪文本,以便在給定的空白表示某個(gè)值的情況下,任何空白都會(huì)被修剪掉。


if(amount.getText().trim().isEmpty()||unit.getText().trim().isEmpty()||

            status.getText().trim().isEmpty()){

        JOptionPane.showMessageDialog(null,"please enter data");

        // errorname2.setText("fill this field");

    }

請(qǐng)確保您將修剪后的數(shù)據(jù)插入到數(shù)據(jù)庫(kù)中。


查看完整回答
反對(duì) 回復(fù) 2023-06-21
?
慕村225694

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊

在應(yīng)用語(yǔ)句之前嘗試驗(yàn)證您的金額字段是否為空try-catch:


if(amount.getText().isEmpty()||unit.getText().isEmpty()||status.getText().isEmpty()){

        JOptionPane.showMessageDialog(null,"please enter data");

        // errorname2.setText("fill this field");

    }else{

        try{

            Class.forName("com.mysql.cj.jdbc.Driver");

            Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/dbfinance","root","1234");

            String sql="insert into util(type_,due_date,month_,amount,units,status_) values(?,?,?,?,?,?)";

            PreparedStatement pstm =con.prepareStatement(sql);

            pstm.setString(1,electype.getSelectedItem().toString());

            pstm.setString(2,date.getText().toString());

            pstm.setString(3,jComboBox1.getSelectedItem().toString());

            pstm.setDouble(4,Double.parseDouble(amount.getText()));

            pstm.setString(5,unit.getText());

            pstm.setString(6,status.getText());

            pstm.executeUpdate();

            JOptionPane.showMessageDialog(null, "success");

            con.close();


        }catch(Exception e){

            JOptionPane.showMessageDialog(null,e);

        }

    }


查看完整回答
反對(duì) 回復(fù) 2023-06-21
  • 2 回答
  • 0 關(guān)注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)