我试图在我准备好的语句中设置一个包含一个字符的字符串,如下所示:
ps.setString(7, String.valueOf(concretizada));
但事情就是这样:我的db列的大小为1。即使它只是一个字符,也会抛出异常:
java.sql.SQLException: ORA-12899: valor muito grande para a coluna "QPL"."TAB_NEGC"."FL_CONCR" (real: 8, máximo: 1)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:208)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1046)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3613)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3694)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1354)
at br.com.reajuste.repositorio.RepositorioTabelaNegociacao.inserirTabela(RepositorioTabelaNegociacao.java:1451)
at br.com.reajuste.repositorio.RepositorioTabelaNegociacao.inserirTabelaNegociacao(RepositorioTabelaNegociacao.java:855)
at br.com.reajuste.repositorio.RepositorioTabelaNegociacao.copiarTabelas(RepositorioTabelaNegociacao.java:837)
at br.com.reajuste.controlador.ControladorReajuste.executarReajuste(ControladorReajuste.java:33)
at br.com.reajuste.gui.Main.main(Main.java:18)
(列值太大)
如何在预准备语句中将char设置为参数?
编辑:我的' concretizada'变量:String concretizada = "N";
if (tabelaNegociacao.getConcretizada()) {
concretizada = "S";
}
答案 0 :(得分:1)
DDL并不是说FL_CONCR
是1个字符长。它表示FL_CONCR
长1 字节。
根据字符的编码方式,字符可以占用多个字节。
将其更改为:
FL_CONCR VARCHAR2(1 CHAR)
它应该有用。
如果您不想重新创建该表:
ALTER TABLE TAB_NEGC MODIFY(FL_CONCR VARCHAR2(1 CHAR));