我的代码:
SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dwDatasource).withTableName("DW.MYTABLE1");
Map<String,Object> parameters1 = new HashMap<String,Object>();
parameters1.put("STRING2", "Entry2");
jdbcInsert.execute(parameters1);我得到了:
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Unable to locate columns for table 'MYTABLE1' so an insert statement can't be generated注意:如果我在jdbctemplate上设置相同的数据源,并且
jdbcTemplate.update("INSERT INTO DW.MYTABLE1 (STRING2) VALUES ('Entry2'));它起作用了
发布于 2019-01-29 11:16:52
定义SimpleJdbcInsert时,除了表名,还需要指定列:
String[] columns = {"column1","column2"}
SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dataSource)
.usingColumns(columns)
.withTableName(table);https://stackoverflow.com/questions/51080610
复制相似问题