3
private Connection conn = DriverManager.getConnection(URL, info);
try {
String sql = "INSERT INTO \"STUD1582251\".\"ACCOUNTS\" VALUES USERNAME=?, PASSWORD=?, PORTFOLIONAME=?";
    PreparedStatement stm = conn.prepareStatement(sql);
    stm.setString(1, user.getUsername());
    stm.setString(2, user.getPassword());
    stm.setString(3, user.getPortfolioName());
    System.out.println(sql);
    stm.executeUpdate();
} catch (SQLException e) {
    e.printStackTrace();
}

例外

SELECT username FROM "STUD1582251"."ACCOUNTS" WHERE username=? 插入“STUD1582251”。“帐户”值 USERNAME=?, PASSWORD=?, PORTFOLIONAME=? java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

4

1 回答 1

7

INSERT SQL 语句必须是:

 String sql = "INSERT INTO \"STUD1582251\".\"ACCOUNTS\" (USERNAME,PASSWORD,PORTFOLIONAME) VALUES (?,?,?)";

PS:如果标识符是保留字,请在标识符周围使用“(双引号) 。

于 2012-09-24T10:24:32.347 回答