我有以下用于创建存储过程的Java代码。为了测试它,我故意将它传递给无效的sql:
public void createStoredProcedure(@NotNull final StoredProcInfo storedProcInfo, @NotNull final ColumnInfoFactory columnInfoFactory, @NotNull final Connection con) {
Statement createProcStmt = null;
try {
List<String> parameterDefinitions = Lists.newArrayList();
for (StoredProcParmInfo parmInfo : storedProcInfo.getInParameters()) {
parameterDefinitions.add(columnInfoFactory.generateParameterDefinition(parmInfo));
}
for (StoredProcParmInfo parmInfo : storedProcInfo.getOutParameters()) {
parameterDefinitions.add(columnInfoFactory.generateParameterDefinition(parmInfo));
}
String createProcSql = String.format("CREATE Procedure %s (%s) AS BEGIN %s END;", storedProcInfo.getName(), StringUtils.join(parameterDefinitions.iterator(), ","), storedProcInfo.getBody());
createProcStmt = con.createStatement();
createProcStmt.execute(createProcSql);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
Closer.close(createProcStmt, logger);
}
}
该方法成功执行。当我查看数据库时,我发现存储过程已创建但标记为无效对象:
为什么在执行创建过程的代码时没有抛出SQLException?这是Oracle驱动程序设置吗?我在网上搜索过但没有找到任何有用的信息。