有没有人在使用带有“;”的 SQL 语句java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
进行sql.execute('...')
( 1 ) 调用时遇到过?(分号)字符。我知道尾随分号会导致 ORA-00911 如此处建议的2所以我已经把它们去掉了)
下面是一个这样的 SQL 语句的示例:
INSERT INTO metadata_property_qualifier(id,version,metadata_property_id,name,overridable,propagated,to_instance,to_subclass,translatable,type,value,value_type)
VALUES (mpr_qualifier_sequence.nextval,0,(select id from metadata_property where metadata_class_id
IN (select id from metadata_class where name = 'UIM_DXTPMLanSwitchError')
AND metadata_property.name='CollisNumberValidity'),'ValueMap',0,0,0,0,0,'[Ljava.lang.String;',unistr('0\00a31'),19)
请注意,其中 [Ljava.lang.String;
有;
字符。有没有办法逃避分号或以某种方式解决它?
代码片段:
sqlFile.eachLine() {
log.info it
if(!it.startsWith('--') && !it.trim().isEmpty()) {
try {
sql.execute(it - ';')
} catch(ex) {
log.error ex
log.info "Rolling back the transaction..."
sql.dataSource.connection.rollback()
}
}
}