java - 错误 java.sql.SQLException : ORA-01722: invalid number while running a Prepared Statement to alter a Sequence

标签 java oracle jdbc prepared-statement ora-01722

sqlStmt = new StringBuffer("  ALTER SEQUENCE "  );  
                    sqlStmt.append( ServerContext.getSchemaName() );
                    sqlStmt.append("SEQ_EDCD_TRACE_NUM");
                    sqlStmt.append( " INCREMENT BY " );
                    sqlStmt.append( " ? " );
pstmt.setLong(1, incval);
pstmt.execute();

最佳答案

您不能将绑定(bind)变量与 DDL 一起使用,例如 ALTER SEQUENCE。您必须将 incval 连接到字符串上。

如果 incval 是一个 int 或一个 long,就不会有任何 SQL 注入(inject)的风险。

关于java - 错误 java.sql.SQLException : ORA-01722: invalid number while running a Prepared Statement to alter a Sequence,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5841131/

相关文章:

java - 为什么导致 StackOverflowError 的递归方法的调用次数在程序运行之间有所不同?

database - oracle数据库中的日期格式保持不变

grails - 当我使用JDBCAppender设置log4j时,Grails抛出ClassNotFoundException

java - SQL异常 : No suitable driver found for url=jdbc:derby

c# - “在 DLL 'OpsConIsDRCPEnabled' 中找不到名为 'OraOps12.dll' 的入口点 - Oracle 12c

java - JTable 中的 JComboBox 不显示选项,只有正确数量的空白选项

java - 通过 API 将上下文参数添加到 Tac 中的 Talend 作业,而无需实际运行它

java - Google App Engine 上的 Stripes 问题

java - Spring Security 是如何跨 Web 应用请求在一个线程中管理 SecurityContext 的?

c# - 将 c# datetime 插入 oracle 表时出现日期格式问题