spring-jdbc

java.sql.SQLException: An attempt by a client to checkout a Connection has timed out

拈花ヽ惹草 提交于 2021-02-19 03:25:09
问题 I have a java client server which is supposed to establish connection pool on startup but its failing on timeout error. There are so many threads on this same issue but none of the solutions worked for me AM using jdk 7 and below is the mchange maven dependency <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.2.1</version> </dependency> jdbc.properties url=jdbc\:sqlserver\://server\\instance;databaseName\=db driver=com.microsoft.sqlserver.jdbc

ORA-00942: table or view does not exist with Spring JDBC Template in Spring Boot

老子叫甜甜 提交于 2021-02-11 13:38:09
问题 I'm getting a weird ORA-00942: table or view does not exist exception while trying to execute database code via Spring JDBC template: 2019-12-26 22:01:36.863[0;39m [31mERROR[0;39m [35m12232[0;39m [2m---[0;39m [2m[ctor-http-nio-3][0;39m [36ma.w.r.e.AbstractErrorWebExceptionHandler[0;39m [2m:[0;39m [ca8305eb] 500 Server Error for HTTP GET "/exs/acs/accounts-links?limit=20&q=632626&showActive=false&systemName=IMMS" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad

HOW TO pass List of objects(a DTO) as single IN parameter to Stored Procedure

戏子无情 提交于 2021-02-07 07:20:31
问题 I want to pass Dto as in parameters and call stored procedure in spring jdbc.Is it possible,In doing so? I want to call stored procedures with dto as in paratmeters instead of setting parameters?Because I have large number of parameters. 回答1: At the moment, there is no way to pass (or return) objects in MySQL stored procedures and functions. BUT, MySQL 5.7 have JSON functions, you can pass a varchar parameter and extract values using JSON_EXTRACT function. See MySQL 5.7 manual: Functions That

Timeouts connecting to a Postgres database on Amazon RDS from Azure

爷,独闯天下 提交于 2021-02-05 20:01:53
问题 I get the following exception in my application after leaving a database connection idle for some amount of time: ... An I/O error occured while sending to the backend.; nested exception is org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.] with root cause java.net.SocketException: Operation timed out at java.net.SocketInputStream.socketRead0(Native Method) The same issue happens in psql AND I don't have issues connecting to a local database, so I'm pretty

Java/Spring JDBC: Batch Insert into 2 Tables: Obtain FK ID from 1st Batch Insert Required for 2nd Table

谁说胖子不能爱 提交于 2021-02-05 10:48:21
问题 I'm using jdbcTemplate to Batch-Insert into 2 tables. The 1st table is easy, and has an ID . The 2nd table has an FK Reference USER_ID which I need to obtain from Table 1 before inserting. Suppose I have this: Main Java Code (here I split up into batches <= 1000) for(int i = 0; i < totalEntries.size(); i++) { // Add to Batch-Insert List; if list size ready for batch-insert, or if at the end, batch-persist & clear list batchInsert.add(user); if (batchInsert.size() == 1000 || i == totalEntries

Writing List of Items using JdbcBatchItemWriter

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 09:40:36
问题 Currently i am using JpaItemWriter to write the list of objects as below which is working fine. Now i want to change the JpaItemWriter to JdbcBatchItemWriter due to performance issue. public class MyItemWriter implements ItemWriter<List<MyDomainObject>> { @Override public void write(List<? extends Lists<MyDomainObject>> items) { JpaItemWriter<MyDomainObject> writer = new JpaItemWriter<>(); for(List<MyDomainObject> o : items) { writer.write(o); } } } Suggest a sample snippets which uses the

How do I connect to AWS RDS MySQL from Java/Spring application using AWS IAM Authentication?

对着背影说爱祢 提交于 2021-01-28 06:05:49
问题 I am new to AWS world and still learning. It's been only a month that I am trying things. I have been looking for it for quite a few days now and haven't been able to find a correct and more appropriate solution. Therefore it would be great if somebody can help me by giving a sample code, provide some pointer or guide in the right direction. I have a AWS RDS MySQL instance and a database created. I have configured " IAM DB AUthentication Enabled " to "Yes". Created an IAM Role and Policy as

Error Handling Spring JdbcTemplate batchUpdate

扶醉桌前 提交于 2021-01-21 09:29:49
问题 I am trying to update thousands of rows in a table using batchUpdate. My requirements are: 1) Assume there are 1000 records in a batch. Record No 235 caused an error. How do I find out which record caused the error. 2) Assume that record 600 did not result in an update (reason could be no record matching the where clause). How can I find out records that did not result in an update. 3) In both scenarios above how can I continue processing the remaining records. 回答1: The only solution after

Spring JDBCTemplates: execute a query with Join

偶尔善良 提交于 2020-12-31 06:43:09
问题 I'm developing an app for DB querying, using Spring Boot and JDBCTemplates. The problem is this: if I have to ask the db on a single table, I have no problems. But, if I have a join, how can I perform this task? More specifically, the SQL commands to create tables are these: CREATE TABLE firewall_items ( id INT NOT NULL AUTO_INCREMENT, firewall_id INT NOT NULL, date DATE, src VARCHAR(15), src_port INT, dst VARCHAR(15), dst_port INT, protocol VARCHAR(4), PRIMARY KEY(id) ); CREATE TABLE

Spring batch: JdbcPagingItemReader doesn't obtain page 1 onwards

余生长醉 提交于 2020-12-15 00:30:46
问题 Here my reader: @Bean public ItemReader<Unitat> itemReader(PagingQueryProvider queryProvider) { return new JdbcPagingItemReaderBuilder<Unitat>() .name("creditReader") .dataSource(this.dataSource) .queryProvider(queryProvider) .rowMapper(this.unitatMapper) .pageSize(2) .build(); } @Bean public SqlPagingQueryProviderFactoryBean queryProvider() { SqlPagingQueryProviderFactoryBean provider = new SqlPagingQueryProviderFactoryBean(); provider.setDataSource(this.dataSource); provider.setSelectClause