我正在使用以下代码将关键字和计数上传到Excel文件。我将keyword_id作为该键的主键。我在Excel文件中有两列。 1.关键字和2.count

我的代码是:

while (rs.next()) {
    System.out.println("inside ");
    String keyword = rs.getString(1);
    int count = rs.getInt(2);
    System.out.println("insert into SEARCHABLE_KEYWORDS values ('"+
        keyword+"','"+count+"')");
    stmtdb.execute("insert into SEARCHABLE_KEYWORDS (keyword_id,keyword,count) values ('"+
        "select Searchable_Keywords_sequence.nextval from dual"+
        "','"+keyword+"','"+count+"')");
    System.out.println(keyword + " " + keyword+" count "+count);
}


但我收到以下错误:

java.sql.SQLException: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1.
 at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6998)
 at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7155)
 at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3151)
 at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:378)
 at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:284)
 at keywordsreader.main(keywordsreader.java:42)

最佳答案

count是保留关键字,因此,如果SEARCHABLE_KEYWORDS表中有一列称为count,则需要将列名放在双引号(“)中

10-05 21:48