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

时间:2022-05-24 01:25:17

I have error for code:

我有代码错误:

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);
}

2 个解决方案

#1


77  

The problem is ;

问题是 ;

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

Remove the ; from above string.

去除 ;从上面的字符串。

#2


1  

I have also received same problem in myBatis.

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

Error:

错误:

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

    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

Solution: select * from tableName where id= '123'; after removing ";" from Where clause(Mybatis Mapper xml), its working!!!!!!

解决方案:从tableName中选择*,其中id ='123';删除“;”后来自Where子句(Mybatis Mapper xml),它的工作!!!!!!

#1


77  

The problem is ;

问题是 ;

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

Remove the ; from above string.

去除 ;从上面的字符串。

#2


1  

I have also received same problem in myBatis.

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

Error:

错误:

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

    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

Solution: select * from tableName where id= '123'; after removing ";" from Where clause(Mybatis Mapper xml), its working!!!!!!

解决方案:从tableName中选择*,其中id ='123';删除“;”后来自Where子句(Mybatis Mapper xml),它的工作!!!!!!