强制转换的字符值无效

vjrehmav  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(276)

我一直收到这个错误, net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.0-SNAPSHOT data exception: invalid character value for cast . 我不知道如何修复它我已经尝试从我的sql查询的值中去掉主键,我不确定数据是否不兼容或者我是否以某种方式声明它是错误的请帮助。我正在尝试将gui中的值插入到现有数据库中。
这是我的密码

String racename, noofswimmers, avgtime, raceontime, tod, winid;
    racename = txtracename.getText();
    noofswimmers = txtnoswimmers.getText();
    avgtime = txtavgtime.getText();
    raceontime = txtraceontime.getText();
    tod = txttod.getText();
    winid = txtwinid.getText();

    try {
        Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
        con = DriverManager.getConnection("jdbc:ucanaccess://C:/Users/Calvin/Documents/SwimGala.accdb");

        pst = con.prepareStatement("insert into tblRace(RaceName,NoSwimmers,AvgTime,RaceOnTime,TimeOfDay,WinID)values(?,?,?,?,?,?)");
        pst.setString(0,racename);
        pst.setString(1,noofswimmers);
        pst.setString(2,avgtime);
        pst.setString(3,raceontime);
        pst.setString(4,tod);
        pst.setString(5,winid);
        pst.executeUpdate();
        JOptionPane.showMessageDialog(this,"Record added");

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(Tabl.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(this,ex);

    } catch (SQLException ex) {
        Logger.getLogger(Tabl.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(this,ex);
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题