Spring Batch – 无法将记录保存到Postgres数据库

huangapple go评论103阅读模式
英文:

Spring Batch - Unable to save the records into Postgres database

问题

I am using the same code: https://stackoverflow.com/questions/61081682/na-caused-by-java-sql-sqlsyntaxerrorexception-ora-00942-table-or-view-does-n and unable to save the records into DB.

我正在使用相同的代码:https://stackoverflow.com/questions/61081682/na-caused-by-java-sql-sqlsyntaxerrorexception-ora-00942-table-or-view-does-n,并且无法将记录保存到数据库。

I already have the table created

我已经创建了表格

CREATE TABLE "BATCH".employee (
rowid_object int4 NOT NULL,
status varchar NULL
)
WITH (
OIDS=FALSE
) ;

-- Permissions

ALTER TABLE "BATCH".employee OWNER TO postgres;

生命周期状态写入器(LifeCycleStatusWriter.java)

@Component
public class EmployeeWriter implements ItemWriter {

  1. @Autowired
  2. @Qualifier(value="postgresDS")
  3. private DataSource dataSourcePostgres;
  4. private NamedParameterJdbcTemplate namedParamJdbcTemplate;
  5. @PostConstruct
  6. private void postConstruct() {
  7. namedParamJdbcTemplate = new NamedParameterJdbcTemplate(this.dataSourcePostgres);
  8. }
  9. String sql = "INSERT INTO BATCH.employee(id, status) VALUES (:rowid_object, :status)";
  10. @SuppressWarnings("unchecked")
  11. @Override
  12. public void write(List<? extends Employee> items) throws Exception {
  13. List<Map<String, Object>> batchValues = new ArrayList<>(items.size());
  14. for (LifeCycleStatus l : items) {
  15. System.out.println("id : "+l.getRowIdObject());
  16. System.out.println("status : "+l.getLifeCycleStatCd());
  17. batchValues.add(new MapSqlParameterSource("id", l.getRowIdObject())
  18. .addValue("status", l.getLifeCycleStatCd()).getValues());
  19. }
  20. int[] updateCounts = namedParamJdbcTemplate.batchUpdate(sql, batchValues.toArray(new Map[items.size()]));
  21. System.out.println(updateCounts);
  22. }

}

写入器(Writer)

@Configuration
public class EmployeeBatchConfig {
private static final String SQL = "SQL HERE";

  1. @Autowired
  2. @Qualifier(value="oracleDS")
  3. private DataSource dataSourceOracle;
  4. @Autowired
  5. @Qualifier(value="postgresDS")
  6. private DataSource dataSourcePostgres;
  7. @Bean(destroyMethod = "")
  8. @StepScope
  9. public JdbcCursorItemReader<Employee> EmployeeReader() throws Exception {
  10. JdbcCursorItemReader<Employee> reader = new JdbcCursorItemReader<>();
  11. reader.setDataSource(this.dataSourceOracle);
  12. reader.setSql(SQL);
  13. reader.setRowMapper(new EmployeeRowMapper());
  14. reader.afterPropertiesSet();
  15. return reader;
  16. }
  17. @Bean
  18. public EmployeeWriter getEmployeeWriter() {
  19. return new EmployeeWriter();
  20. }

}

错误信息(Error)

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO program.BATCH.employee(rowid_object, status) VALUES (?, ?)]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "batch.employee" does not exist
Position: 13
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:647) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:936) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.batchUpdate(NamedParameterJdbcTemplate.java:366) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.batchUpdate(NamedParameterJdbcTemplate.java:354) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at com.mastercard.customer.data.management.writer.LifeCycleStatusWriter.write(LifeCycleStatusWriter.java:48) ~[classes/:na]
at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:193) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:159) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:294) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:217) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:77) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
at org

英文:

I am using the same code: https://stackoverflow.com/questions/61081682/na-caused-by-java-sql-sqlsyntaxerrorexception-ora-00942-table-or-view-does-n and unable to save the records into DB.

I already have the table created

  1. CREATE TABLE &quot;BATCH&quot;.employee (
  2. rowid_object int4 NOT NULL,
  3. status varchar NULL
  4. )
  5. WITH (
  6. OIDS=FALSE
  7. ) ;
  8. -- Permissions
  9. ALTER TABLE &quot;BATCH&quot;.employee OWNER TO postgres;

LifeCycleStatusWriter.java

  1. @Component
  2. public class EmployeeWriter implements ItemWriter&lt;Employee&gt; {
  3. @Autowired
  4. @Qualifier(value=&quot;postgresDS&quot;)
  5. private DataSource dataSourcePostgres;
  6. private NamedParameterJdbcTemplate namedParamJdbcTemplate;
  7. @PostConstruct
  8. private void postConstruct() {
  9. namedParamJdbcTemplate = new NamedParameterJdbcTemplate(this.dataSourcePostgres);
  10. }
  11. String sql = &quot;INSERT INTO BATCH.employee(id, status) VALUES (:rowid_object, :status)&quot;;
  12. @SuppressWarnings(&quot;unchecked&quot;)
  13. @Override
  14. public void write(List&lt;? extends Employee&gt; items) throws Exception {
  15. List&lt;Map&lt;String, Object&gt;&gt; batchValues = new ArrayList&lt;&gt;(items.size());
  16. for (LifeCycleStatus l : items) {
  17. System.out.println(&quot;id : &quot;+l.getRowIdObject());
  18. System.out.println(&quot;status : &quot;+l.getLifeCycleStatCd());
  19. batchValues.add(new MapSqlParameterSource(&quot;id&quot;, l.getRowIdObject())
  20. .addValue(&quot;status&quot;, l.getLifeCycleStatCd()).getValues());
  21. }
  22. int[] updateCounts = namedParamJdbcTemplate.batchUpdate(sql, batchValues.toArray(new Map[items.size()]));
  23. System.out.println(updateCounts);
  24. }
  25. }

Writer

  1. @Configuration
  2. public class EmployeeBatchConfig {
  3. private static final String SQL = &quot;SQL HERE&quot;;
  4. @Autowired
  5. @Qualifier(value=&quot;oracleDS&quot;)
  6. private DataSource dataSourceOracle;
  7. @Autowired
  8. @Qualifier(value=&quot;postgresDS&quot;)
  9. private DataSource dataSourcePostgres;
  10. @Bean(destroyMethod = &quot;&quot;)
  11. @StepScope
  12. public JdbcCursorItemReader&lt;Employee&gt; EmployeeReader() throws Exception {
  13. JdbcCursorItemReader&lt;Employee&gt; reader = new JdbcCursorItemReader&lt;&gt;();
  14. reader.setDataSource(this.dataSourceOracle);
  15. reader.setSql(SQL);
  16. reader.setRowMapper(new EmployeeRowMapper());
  17. reader.afterPropertiesSet();
  18. return reader;
  19. }
  20. @Bean
  21. public EmployeeWriter getEmployeeWriter() {
  22. return new EmployeeWriter();
  23. }
  24. }

Error:

  1. org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO program.BATCH.employee(rowid_object, status) VALUES (?, ?)]; nested exception is org.postgresql.util.PSQLException: ERROR: relation &quot;batch.employee&quot; does not exist
  2. Position: 13
  3. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  4. at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  5. at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  6. at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  7. at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:647) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  8. at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:936) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  9. at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.batchUpdate(NamedParameterJdbcTemplate.java:366) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  10. at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.batchUpdate(NamedParameterJdbcTemplate.java:354) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  11. at com.mastercard.customer.data.management.writer.LifeCycleStatusWriter.write(LifeCycleStatusWriter.java:48) ~[classes/:na]
  12. at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:193) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  13. at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:159) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  14. at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:294) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  15. at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:217) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  16. at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:77) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  17. at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  18. at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  19. at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  20. at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  21. at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  22. at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  23. at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  24. at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  25. at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  26. at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:208) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  27. at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  28. at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:410) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  29. at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:136) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  30. at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:319) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  31. at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:147) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  32. at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) [spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  33. at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:140) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  34. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
  35. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
  36. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
  37. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
  38. at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) [spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  39. at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  40. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  41. at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) [spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
  42. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  43. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  44. at com.sun.proxy.$Proxy72.run(Unknown Source) [na:na]
  45. at com.mastercard.customer.data.management.CustomerProfileStagingBatchApplication.run(CustomerProfileStagingBatchApplication.java:50) [classes/:na]
  46. at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
  47. at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
  48. at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
  49. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
  50. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
  51. at com.mastercard.customer.data.management.CustomerProfileStagingBatchApplication.main(CustomerProfileStagingBatchApplication.java:38) [classes/:na]
  52. Caused by: org.postgresql.util.PSQLException: ERROR: relation &quot;batch.employee&quot; does not exist
  53. Position: 13
  54. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578) ~[postgresql-42.2.11.jar:42.2.11]
  55. at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313) ~[postgresql-42.2.11.jar:42.2.11]
  56. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331) ~[postgresql-42.2.11.jar:42.2.11]
  57. at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:832) ~[postgresql-42.2.11.jar:42.2.11]
  58. at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:874) ~[postgresql-42.2.11.jar:42.2.11]
  59. at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1569) ~[postgresql-42.2.11.jar:42.2.11]
  60. at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128) ~[HikariCP-3.4.2.jar:na]
  61. at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java) ~[HikariCP-3.4.2.jar:na]
  62. at org.springframework.jdbc.core.JdbcTemplate.lambda$batchUpdate$2(JdbcTemplate.java:950) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  63. at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617) ~[spring-jdbc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
  64. ... 45 common frames omitted

config details

  1. # ORACLE DATASOURCE - Primary
  2. spring.datasource.url=jdbc:oracle:thin:@/****:1527/test
  3. spring.datasource.username=***
  4. spring.datasource.password=****
  5. spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
  6. # PostgreSQL DB - &quot;Secondary&quot;
  7. postgres.datasource.url=jdbc:postgresql://localhost:5432/test?currentSchema=BATCH
  8. postgres.datasource.username=****
  9. postgres.datasource.password=****
  10. postgres.datasource.driver-class-name=org.postgresql.Driver
  11. #By default, Spring runs all the job as soon as it has started its context.
  12. spring.batch.job.enabled=false
  13. # Chunk Size to save data
  14. spring.chunk.size=200
  15. spring.batch.initialize-schema=always

Database config

  1. @Configuration
  2. public class DatabaseConfig {
  3. @Autowired
  4. private Environment env;
  5. @Bean(name = &quot;oracleDS&quot;)
  6. public DataSource batchDataSource() {
  7. return DataSourceBuilder.create().url(env.getProperty(&quot;spring.datasource.url&quot;))
  8. .driverClassName(env.getProperty(&quot;spring.datasource.driver-class-name&quot;))
  9. .username(env.getProperty(&quot;spring.datasource.username&quot;))
  10. .password(env.getProperty(&quot;spring.datasource.password&quot;)).build();
  11. }
  12. // All metadata tables are present here
  13. @Primary
  14. @Bean(name = &quot;postgresDS&quot;)
  15. public DataSource mysqlBatchDataSource() {
  16. return DataSourceBuilder.create().url(env.getProperty(&quot;postgres.datasource.url&quot;))
  17. .driverClassName(env.getProperty(&quot;postgres.datasource.driver-class-name&quot;))
  18. .username(env.getProperty(&quot;postgres.datasource.username&quot;))
  19. .password(env.getProperty(&quot;postgres.datasource.password&quot;)).build();
  20. }
  21. }

答案1

得分: 1

你使用双引号(&quot;BATCH&quot;.employee)创建了你的表的模式,现在这些名称是区分大小写的。&quot;BATCH&quot;.employeeBATCH.employee 是两个不同的名称。尝试使用以下代码:

  1. String sql = "INSERT INTO \"BATCH\".employee(rowid_object, status) VALUES (:rowid_object, :status)";
英文:

You created your tables's schema with double quotes (&quot;BATCH&quot;.employee), and now the names are case sensitive. Ref

&quot;BATCH&quot;.employee and BATCH.employee are two different names.
Try to use this

  1. String sql = &quot;INSERT INTO \&quot;BATCH\&quot;.employee(rowid_object, status) VALUES (:rowid_object, :status)&quot;;

huangapple
  • 本文由 发表于 2020年4月8日 01:27:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/61085861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定