ora-00911错误

i7uq4tfw  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(272)

我有一个系统,在将请求发送到数据库之前,通过占位符的值更改占位符。

INSERT INTO MYAPP.LOGPRODUCAO
(NOMERECURSOCONJUNTO, ORDEMPRODUCAO, OPERACAO, QTDEBOAS, INICIO, FIM, MATRICULAFUNCIONARIO, STATUS)
VALUES(
    {nomeRecursoConjunto},
    CAST({ordemProducao} as VARCHAR(100)),
    {operacao},
    TO_NUMBER({qtdeBoas}),
    TO_TIMESTAMP({inicio}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    TO_TIMESTAMP({fim}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    {matriculaFuncionario},
    {status})

替换后,会变成这样:

INSERT INTO MYAPP.LOGPRODUCAO
(NOMERECURSOCONJUNTO, ORDEMPRODUCAO, OPERACAO, QTDEBOAS, INICIO, FIM, MATRICULAFUNCIONARIO, STATUS)
VALUES(
    'NAME',
    CAST(43267 as VARCHAR(100)),
    10,
    TO_NUMBER('0.0'),
    TO_TIMESTAMP('2020-07-20T14:40:43.819', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    TO_TIMESTAMP('2020-07-20T15:28:28.359', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    2389,
    'I')

当我接受上面的查询并通过dbeaver执行时,它就工作了。将插入该行。当我运行jdbc时,它返回以下错误:

Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: caractere inválido
    at 
...
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    ...
Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: caractere inválido
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1054)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:623)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:252)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:612)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:213)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:37)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:896)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1119)
    at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1661)
    at oracle.jdbc.driver.OracleStatement.executeLargeUpdate(OracleStatement.java:1626)
    at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1613)
    at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:282)
    ... 52 more
Caused by: Error : 911, Position : 137, Sql = INSERT INTO MYAPP.LOGPRODUCAO
(NOMERECURSOCONJUNTO, ORDEMPRODUCAO, OPERACAO, QTDEBOAS, INICIO, FIM, MATRICULAFUNCIONARIO, STATUS)
VALUES(
    'NAME',
    CAST(43267 as VARCHAR(100)),
    10,
    TO_NUMBER('0.0'),
    TO_TIMESTAMP('2020-07-20T14:40:43.819', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    TO_TIMESTAMP('2020-07-20T15:28:28.359', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    2389,
    'I'), OriginalSql = INSERT INTO MYAPP.LOGPRODUCAO
(NOMERECURSOCONJUNTO, ORDEMPRODUCAO, OPERACAO, QTDEBOAS, INICIO, FIM, MATRICULAFUNCIONARIO, STATUS)
VALUES(
    'NAME',
    CAST(43267 as VARCHAR(100)),
    10,
    TO_NUMBER('0.0'),
    TO_TIMESTAMP('2020-07-20T14:40:43.819', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    TO_TIMESTAMP('2020-07-20T15:28:28.359', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'),
    2389,
    'I'), Error Msg = ORA-00911: caractere inválido
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498)
    ... 66 more

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题