executeUpdate() returns zero despite correct execution

前端 未结 3 1186
北恋
北恋 2021-01-25 18:10

create_PaperBean.java

package Beans;

import java.sql.SQLException;
import java.sql.Statement;
import java.util.loggin         


        
3条回答
  •  萌比男神i
    2021-01-25 18:35

    If we take a look at the Statement.executeUpdate javadoc we see that it always return 0 for DDL statements (in your case create table is a DDL statement):

    Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

    Returns: either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing

    You can assume that the statement execution is successful if you don't get a SQLException.

提交回复
热议问题