错误java.sql.SQLException:ORA-00911:无效字符

use*_*433 38 sql oracle jdbc

我的代码有错误:

String sql = "CREATE USER ken IDENTIFIED BY 11;";

try {
    Class.forName("oracle.jdbc.OracleDriver");
    con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "kenilyas");
    System.out.println("1111111111111");
    System.out.println("222222");
    pst = con.prepareStatement(sql);
    System.out.println("333333");
    try {
        System.out.println("333333");
        pst.execute();
        System.out.println("creating");
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
} catch (Exception e) {
    JOptionPane.showMessageDialog(null, e);
}
Run Code Online (Sandbox Code Playgroud)

小智 91

问题是 ;

sql = "CREATE USER ken IDENTIFIED BY 11;";
Run Code Online (Sandbox Code Playgroud)

;从上面的字符串中删除.

  • 谢谢!如此愚蠢,让系统对此不灵活或不投入非常明确的期望 (5认同)

小智 5

我在myBatis中也收到了同样的问题。

错误:

### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
Run Code Online (Sandbox Code Playgroud)

解:

select * from tableName where id= '123';
Run Code Online (Sandbox Code Playgroud)

";"从Where子句(Mybatis Mapper xml)中删除后,其工作正常。