错误 java.sql.SQLException: ORA-00911: 无效字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22435756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:22:18 来源:igfitidea点击:
Error java.sql.SQLException: ORA-00911: invalid character
提问by user3425433
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);
}
回答by Abhishek
The problem is ;
问题是 ;
sql = "CREATE USER ken IDENTIFIED BY 11;";
Remove the ;
from above string.
;
从上面的字符串中删除。
回答by user3425433
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.
";"
从Where子句(Mybatis Mapper xml)中删除后,它的工作。