【Spring123】JdbcTemplate初使用 以及 ORA-01858: a non-numeric character was found where a numeric was expected, ORA-00911: invalid character解决

摘要:
“;26}27value+=”)“;28Stringsql=String.format;29if{30returnnull;31}else{32returnjdbcTemplate.batchUpdate;33}34}参数如下表所示,例如:tds3EodSnapshotPSHRheaderListtds3EedSnapshotPSHR batchArgs报告错误:原因:to_timestamp无法将其识别为Oracle内置函数解决方案:https://stackoverflow.com/questions/13005343/error-ora-01858-a-non-numeric-character-was-found-where-a-numeric-was-expecteinsertintoSHARK_REGDATA_DEV03.EOD_SNAPSHOT_PSHRvalues (?

参考:

https://www.cnblogs.com/wangyujun/p/10687780.html

https://www.cnblogs.com/caoyc/p/5630622.html

实例:

insert into SHARK_REGDATA_DEV03.EOD_SNAPSHOT_PSHR (BANK_ID, NAME, RECORD_DATETIME, PSHR_ID, LOCATION) values (?,?,?,?,?)

 1 {...
 2 
 3 this.tds3EodSnapshotPSHRheaderList =dataRows.get(0).columnNames();
 4 this.tds3EodSnapshotPSHRbatchArgs = new ArrayList<Object[]>();
 5 for(DataRow row : dataRows){
 6                 Object[] batchArgs = new Object[tds3EodSnapshotPSHRheaderList.size()];
 7                 int i = 0;
 8                 for (String column : tds3EodSnapshotPSHRheaderList) {
 9                     batchArgs[i++] = row.get(column);
10                 }
11                 this.tds3EodSnapshotPSHRbatchArgs.add(batchArgs);
12             }
13 
14 
15 dao.insertEodSnapshotPSHR(tds3EodSnapshotPSHRheaderList, tds3EodSnapshotPSHRbatchArgs);
16 
17 ...
18 }
19 
20 
21 
22 public int[] insertEodSnapshotPSHR(List<String> headerList, List<Object[]> batchArgs){
23     String value = "(?";
24     for(int i=1; i<headerList.size();i++){
25         value += ",?";
26     }
27     value += ")";
28     String sql = String.format("insert into %s.EOD_SNAPSHOT_PSHR (%s) values "+value, schema, headerList.toString().replace("[","").replace("]",""));
29     if (batchArgs.isEmpty()) {
30         return null;
31     } else {
32         return jdbcTemplate.batchUpdate(sql,batchArgs);
33     }
34 }

其中参数如下表举例:

tds3EodSnapshotPSHRheaderList
tds3EodSnapshotPSHRbatchArgs

【Spring123】JdbcTemplate初使用 以及 ORA-01858: a non-numeric character was found where a numeric was expected, ORA-00911: invalid character解决第1张

 报错:

【Spring123】JdbcTemplate初使用 以及 ORA-01858: a non-numeric character was found where a numeric was expected, ORA-00911: invalid character解决第2张

原因:

to_timestamp 无法识别为Oracle内置函数

解决方案:

https://stackoverflow.com/questions/13005343/error-ora-01858-a-non-numeric-character-was-found-where-a-numeric-was-expecte

insert into SHARK_REGDATA_DEV03.EOD_SNAPSHOT_PSHR (BANK_ID, NAME, RECORD_DATETIME, PSHR_ID, LOCATION) values (?,?,to_timestamp(?,'YYYY-MM-DD HH24:MI:SS'),?,?)

另一个实例中使用jdbcTemplate.update又遇到ORA-00911: invalid character

 https://blog.csdn.net/jiangyu1013/article/details/70237550

 原因:

sql结尾处多了一个" ; " 

【Spring123】JdbcTemplate初使用 以及 ORA-01858: a non-numeric character was found where a numeric was expected, ORA-00911: invalid character解决第3张

免责声明:文章转载自《【Spring123】JdbcTemplate初使用 以及 ORA-01858: a non-numeric character was found where a numeric was expected, ORA-00911: invalid character解决》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Android学习笔记12:图像渲染(Shader)maximo功能修改笔记下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

spring ---JdbcTemplate

1.JdbcTemplate Spring提供的一个操作数据库的技术JdbcTemplate,是对Jdbc的封装。 JdbcTemplate可以直接操作数据库,加快效率,而且学这个JdbcTemplate也是为声明式事务做准备,毕竟要对数据库中的数据进行操纵! JdbcTemplate中并没有提供一级缓存,以及类与类之间的关联关系!就像是spring提供的...

jdbcTemplate 获取数据表结构

jdbcTemplate 操作方法  Java代码   /**  *1.方法一:  */   String sql = "select * from "+ tableName;   //RowCountCallbackHandler rcch = new RowCountCallbackHandler();   //this.jdbcTemplate...

SpringBoot 数据篇之使用JDBC

SpringBootTutorial :: Data :: Jdbc 简介 API execute update query 实战 配置数据源 完整示例 引申和引用 简介 Spring Data 包含对 JDBC 的存储库支持,并将自动为 CrudRepository 上的方法生成 SQL。对于更高级的查询,提供了 @Query 注解。 当...

[JavaWeb]SpringSecurity-OAuth2.0 统一认证、资源分离的配置,用于分布式架构、模块化开发的认证体系

前言 关于 OAuth2.0的认证体系,翻阅了好多资料,RCF 文档太多,看了一半就看不下去了,毕竟全英文的文档看起来,是有一点让我烦躁,但也对 OAuth2.0的认证流程有了一个基本的概念,之前用 SpringSecurity 做了一个基于 RBAC 的权限管理系统的基础配置,所以对 SpringSecurity 算是比较了解了,于是 OAuth2.0...

学习Spring Boot:(二十四)多数据源配置与使用

前言 随着业务量增大,可能有些业务不是放在同一个数据库中,所以系统有需求使用多个数据库完成业务需求,我们需要配置多个数据源,从而进行操作不同数据库中数据。 正文 JdbcTemplate 多数据源 配置 需要在 Spring Boot 中配置多个数据库连接,当然怎么设置连接参数的 key 可以自己决定, 需要注意的是 Spring Boot 2.0 的默...

Spring 中使用了哪些设计模式?

好了,话不多说,开始今天的内容。spring中常用的设计模式达到九种,我们举例说明。 1、简单工厂模式 又叫做静态工厂方法(StaticFactory Method)模式,但不属于23种GOF设计模式之一。  简单工厂模式的实质是由一个工厂类根据传入的参数,动态决定应该创建哪一个产品类。  spring中的BeanFactory就是简单工厂模式的体现,根据...