Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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 为什么';t insert语句是否创建新行?_Java_Mysql_Database_Insert - Fatal编程技术网

Java 为什么';t insert语句是否创建新行?

Java 为什么';t insert语句是否创建新行?,java,mysql,database,insert,Java,Mysql,Database,Insert,我的insert语句应该在每次运行时创建一个新行,但它没有。我也没有任何错误 @Override public void addToDatabase() { try { Connection myConn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:8889/Bank", "kculbreth36", "Gerder11"); PreparedState

我的insert语句应该在每次运行时创建一个新行,但它没有。我也没有任何错误

    @Override
public void addToDatabase() {
    try {
        Connection myConn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:8889/Bank", "kculbreth36",
                "Gerder11");
        PreparedStatement pstmt = conn
                .prepareStatement("INSERT INTO budgeting (GrossPay, TakehomePay, Tips) VALUE (?,?,?)");
        pstmt.setDouble(1, gross);
        pstmt.setDouble(2, tax);
        pstmt.setInt(3, tips);
        pstmt.executeUpdate();
        conn.close();

    } catch (Exception exc) {
        exc.printStackTrace();
    }
}

问题是您使用
myConn
作为连接,但使用
conn
创建一个准备好的语句。因此,您的
conn
可能单独执行,也可能不提交(并且连接未处于自动提交模式),或者在单独的数据库模式中执行(您没有提供足够的相关信息)。事实上,该语句应该抛出一个
SQLException
,因为insert语句的语法应该使用“
VALUES
”关键字,而不是“
VALUE
”。

它应该是VALUE(?,,?)@tha07,但没有错误-奇怪或错误。对此进行了更改,表上仍然没有变化。你确定你在调用这个方法吗?在我看来,我是这样调用它的,所以我不确定为什么它不起作用'income i=new income();i.显示日期();一、收入();i.addToDatabase()`