Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.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_Sql_Database_User Interface_Ms Access - Fatal编程技术网

Java 强制转换的字符值无效

Java 强制转换的字符值无效,java,sql,database,user-interface,ms-access,Java,Sql,Database,User Interface,Ms Access,我不断收到此错误,net.ucanaccess.jdbc.UcanaccessSQLException:ucaesc:::5.0.0-快照数据异常:强制转换的字符值无效。我不确定如何修复我已尝试在sql查询的值部分省略主键,我不确定数据是否不兼容,或者我是否以某种方式声明它是错误的,请帮助。我试图将GUI中的值插入到现有数据库中 这是我的密码 String racename, noofswimmers, avgtime, raceontime, tod, winid; racen

我不断收到此错误,
net.ucanaccess.jdbc.UcanaccessSQLException:ucaesc:::5.0.0-快照数据异常:强制转换的字符值无效
。我不确定如何修复我已尝试在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);
    }

传递给
INSERT
语句参数的值是什么,表中相应列的数据类型是什么?您可能正在尝试将无法隐式转换的值传递给列所需的数据类型。数据库中第一行的值为:RAC001、6、96.4、-1、08:30:00、Tom2473。在access中,列的数据类型如下:RaceName(短文本)、noswimers(数字)、AvgTime(数字)、RaceOnTime(是/否)、TimeOfDay(日期/时间)、WinID(短文本)。我在access中工作已经多年了,所以无法提供实际答案,但我知道它对日期时间数据很敏感。也许可以尝试不使用
TimeOfDay
列的代码,看看这是否是问题所在。如果是,您可能想写一个新问题,重点是如何处理特定的输入参数。传递给
INSERT
语句参数的值是什么,表中相应列的数据类型是什么?您可能正在尝试将无法隐式转换的值传递给列所需的数据类型。数据库中第一行的值为:RAC001、6、96.4、-1、08:30:00、Tom2473。在access中,列的数据类型如下:RaceName(短文本)、noswimers(数字)、AvgTime(数字)、RaceOnTime(是/否)、TimeOfDay(日期/时间)、WinID(短文本)。我在access中工作已经多年了,所以无法提供实际答案,但我知道它对日期时间数据很敏感。也许可以尝试不使用
TimeOfDay
列的代码,看看这是否是问题所在。如果是,您可能想写一个新问题,重点是如何处理特定的输入参数。