Questions tagged [spring-jdbc]
Spring JDBC is a part of Data access layer provided by Spring. The Spring Framework takes care of all the low-level details that can make JDBC such a tedious API to develop with such as database connections, creating prepare statements, process exceptions etc.,
2,286
questions
0
votes
0
answers
14
views
How to define a foreign key in JPA entity?
I have a query for Customer table creation.
CREATE TABLE `customer` (
`cus_name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(20) NOT NULL,
`phone` varchar(15) NOT NULL,
...
0
votes
0
answers
17
views
Error executing DDL alter table movie add constraint FKbxdxfgkluuxl5xjcy7wr34uib foreign key (studio_id) references studio (studio_id) via JDBC Statem
Error executing DDL alter table movie add constraint FKbxdxfgkluuxl5xjcy7wr34uib foreign key (studio_id) references studio (studio_id) via JDBC Statement
It's referencing same table
Like this one:
...
0
votes
0
answers
20
views
Spring boot 2.6.6 MSSQL connection issue
After upgrading to spring boot 2.6.6 in production, constantly experiencing db connection issues
like
com.microsoft.sqlserver.jdbc.SQLServerException: The query has timed out. The query has timed out....
0
votes
1
answer
38
views
Docker dies executing JDBC Query
I'm running a spring boot project in docker and I'm executing the following JDBC code:
SqlRowset rowset = jdbcTemplate.queryForRowSet(queryString);
The query string is the following:
SELECT *
FROM ...
0
votes
1
answer
31
views
Generic RowMapper JDBC
I am trying to create a generic row mapper for JDBC.
My initial attempt looks like:
public class GenericRowMapper<T> implements RowMapper<T> {
private final Class<?> clazz;
...
0
votes
0
answers
11
views
Executing any SQL (DDL, Select, Stored Procs) via JDBC?
So I have been given a task of implementing a REST end point that takes any possible SQL related string (DDL, select, delete, insert, stored proc execution ...) execute it and then return the ...
-1
votes
0
answers
22
views
How I can read on batches from database in Java? [duplicate]
Is there any possibility to read records in the database in batches and specify the size of the batch? I am using Spring and JDBC?
0
votes
1
answer
32
views
Unable to create retry-able datasource for spring boot jdbc
I would like to add the retry feature for database connection certain number of times until the app acquires it. For the I have used the spring-retry on the DataSource but it is not working. It is ...
0
votes
1
answer
25
views
Mysql Innodb Deadlock for not locked queries
I have a strange situation, two identicaly conflicting queries (made by throw different application thread to the same record). The second one will fail with a DeadLock error.
The query is a very ...
-1
votes
0
answers
42
views
How to speed up JDBC Batch Update Prepared Statement
I have a data structure of "List<LinkedHashMap<String, Object>> dataFromExcel" which stores the read data from an Excel file. Each list represents a row, while the LinkedHashMap ...
0
votes
1
answer
29
views
There is other option to connect spring boot to db2?
I'm working with Spring boot, and I need to use a db2 database connection, currently is configured to work with maven and properties, but first I need to create the jks file, and testing part doesn't ...
0
votes
1
answer
23
views
How can I create a db2 connection in Spring boot without use application.properties?
I need to build a connection to db2 database, but I can not use application.properties at this moment, so how can I create this connection?
0
votes
0
answers
48
views
Best approach to query an Optional with Spring JDBC
Well, yes, I want to query an Optional result, consider given SQL:
SELECT foo
FROM bar
WHERE baz = 123
LIMIT 1
This query returns either a row with some value, say some String, or no rows at all.
...
0
votes
1
answer
46
views
Multi threaded transactional inserts with spring data jdbc
I'm using NamedParameterJdbcTemplate. I need to inserts data to 5 different tables within a transaction.
The sequential execution of inserts take long time & I need to optimize the time taken for ...
0
votes
0
answers
51
views
Spring JdbcTemplate change schema on every request
I need to change schema name for every request. I am using SpringBoot JdbcTemplate as below:
jdbcTemplate.execute("set search_path = " + schemaName); //postgres
Few requests are successful ...
0
votes
0
answers
74
views
Getting BadSqlGrammarException in spring batch
I have recently tried to update spring boot version from 2.3.3.RELEASE to 2.6.7.
with this version change I had modified syntax for initialize-schema in application.yml as below.
Old code
spring:
...
1
vote
1
answer
43
views
Spring Boot JPA/JDBC batching findById works but findOneByX not working
I am using Spring Boot JPA, I have enabled batching by ensuring the following lines are in the my application.properties:
spring.jpa.properties.hibernate.jdbc.batch_size=1000
spring.jpa.properties....
0
votes
0
answers
20
views
IlegalStateException: Cache already created: 'database-code'
I have a spring boot application where I use mssql-jdbc to connect to my sql-server database and I am using Hikari connection pool. There is a line of code in my application which creates a ...
0
votes
0
answers
30
views
Alternative to "JdbcTemplate" on migration from "Spring-boot" to "Quarkus"
I'm new to Quarkus and I'm analysing the migration viability of a quite complex "Spring Boot" application.
One of the biggest challenges we have is regarding database access, which is ...
0
votes
0
answers
53
views
jdbc request parameters are not passed to the h2 database
runtime environment:
java-17-spring-jdbc
maven dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</...
0
votes
1
answer
17
views
SimpleJdbcInsert mixes column names from different databases in MySQL
I have recently upgraded spring framework from 5.0.3 to 5.3.12 and mysql from 5.7 to 8.
I am adding new columns in DB and corresponding fields in model class. but it is unable to store the value for ...
-1
votes
4
answers
67
views
Postman Post Request column cannot be found error(JDBC/MYSQL/AWS)
I am working on an independent JDBC/Springboot project and I am having a lot of trouble actually posting any data from postman into MySQL. I have tried looking everywhere and I am at the point where I ...
0
votes
1
answer
35
views
Spring Boot/Spring Batch: Using and configuring two DataSource via app properties
I'm working with Spring Boot/Spring Batch, and need to provide two jdbc Data Sources.
I can't find a way to automatically load the config parameters from my application.properties.
//...
0
votes
1
answer
40
views
"spring-jdbc" and "spring-web" compatibility with Quarkus
I'm new to Quarkus and I'm analysing the migration viability of a quite complex Spring Boot application.
This post raise some good questions regarding our intention on doing so with such application, ...
0
votes
0
answers
81
views
Spring 2.7 MySQL Data Source
I am trying to configure a simple MySQL data source for a Spring Boot application.
The documentation seems to focus on configuring a "custom" data source, whilst I am interested in a basic, ...
0
votes
1
answer
71
views
How to send the data finded in the controller to a view?
I try to do a java web application using:
SpringBoot
Mysql
JDBC
Design pattern: MVC, DAO
And Thymeleaf
I think i understood than:
I must create a class for every Entity and a DAO classe who use the ...
0
votes
0
answers
45
views
String array passed to Oracle stored procedure from Spring is not being inserted
I am trying to a invoke stored procedure which accepts string array as input and has no output.
In my procedure, I'm just looping through array elements to insert them into a table.
To pass string ...
0
votes
1
answer
196
views
Passing an array to stored procedure using Spring Boot JDBC
I am trying to execute an Oracle stored procedure, which takes array of number as input, from Spring Boot JDBC.
The Oracle procedure executes fine in SQL Developer, however I am not able to pass the ...
1
vote
1
answer
42
views
Spring: Issue with passing Interface to controller constructor
Below is the problem I'm facing.
While starting the dev tools I'm getting the below error
Parameter 0 of constructor in tacos.web.DesignTacoController required a bean of type 'tacos.data....
1
vote
0
answers
69
views
Spring Boot multiple datasources on same database
I was reviewing a code which seems to lose connection to DB approximately once a month intermittently. It leaves no logs on DB side but server prints a log of Connection closed by peer.
Its a Spring ...
0
votes
0
answers
25
views
Can I configure Spring JDBC without annotations on domain classes? [duplicate]
I'm working on developing a prototype application in Spring and have been using spring-jdbc to interact with the database. I would like my domain classes to not have a dependency on Spring JDBC but I ...
0
votes
1
answer
45
views
I can't call the function using jdbc, but if it is pipelined, then everything works
I using spring jdbc and oracle 12.
I can't get a response from the package function. But if I use exactly the same function but with the pipeline everything works.
Created a package and declared 2 ...
1
vote
1
answer
154
views
Passing Arraylist<String> as parameters for JDBCTemplate with "in" statement in SQL query
I am receiving an ArrayList of string as parameters and I want to use it as parameters in the jdbc. I tried using it with batchUpdate but in that case I need to create the List<Object[]> and I ...
0
votes
0
answers
159
views
Upgrade Spring version from 4.1.1 to 5.3.18
I have upgraded my spring version from 4.1.1 to 5.3.18 ,but after updating I am getting Cannot resolve type SimpleJDbcTemplate.
It is not loading up the class from spring-jdbc dependency.(version:5.3....
0
votes
1
answer
94
views
How to Iterate through ResultSet
My SELECT_QUERY_RETURNS_LIST returns 5 results, But following while loop prints only 4.
jdbcTemplate.query(SELECT_QUERY_RETURNS_LIST, new RowCallbackHandler() {
public void processRow(ResultSet ...
0
votes
2
answers
59
views
JSP table not display data from database
I try everything but it still not working.I use tomcat 9 and java 8.
I already check the database connectivity and it's fine.
Data just don't display in jsp file.
sorry for my english.
This is pom ...
1
vote
1
answer
202
views
How to write Java that calls a package function? Making a slight change to working Java code
With the help provided in the response to my previous question:
Invalid Index trying to call a simple Oracle PROCEDURE from Java
I was able to call an Oracle package procedure that returns a single ...
0
votes
1
answer
203
views
How to execute sql query from file in spring boot?
I am running a spring boot application where I have to run SQL statements that I have written .sql file is saved in the resource directory.
I don't want to run the script on the application startup. I ...
1
vote
0
answers
14
views
Config server - refresh loads removed properties from database
I am using a composite config server profile to load properties from native and jdbc. My service starts up loading the properties from both native and database table without any issue.
At runtime, I ...
0
votes
1
answer
330
views
How to get millions of data from table and insert another table with spring-jdbc
I have to read 2 millions of record from oracle db with spring jdbc and insert all records to another table.First of all, I tried to get all data with parallel select statement by using spring ...
0
votes
1
answer
205
views
How do I have Springboot access a Postgresql database on Heroku
I am in the process of uploading an application I am running on my local PC to Heroku. It has a Springboot backend accessing a Postgresql database and a React\Axios front end.
I uploaded the source to ...
0
votes
1
answer
54
views
Strange memory grow in temporaryLobs while fetching CLOB with oracle jdbc driver in java app
Goodday everyone.
Faced strange OOM after switching from reading varchar field to clob from Oracle database in java application.
(We are using oracle.jdbc.driver with bonecp connection pool + spring ...
0
votes
0
answers
134
views
How to map data with one-to-many relationship in spring JDBC?
I would like to ask for suggestions from all of you guys, which is the best choice to fetch data with ONE TO MANY relationship using Spring JDBC? I decide to use Spring JDBC because I have a complex ...
0
votes
1
answer
137
views
Access denied for user 'root '@'localhost' " when connecting to mysql
I try to connect to a mysql database in a spring project and error occurred.
create connection error, url: jdbc:mysql://localhost:3306/IwebManager?useUnicode=true&characterEncoding=utf8&...
1
vote
3
answers
576
views
Found 0 JPA repository interfaces after I ran my spring boot application [duplicate]
1. UserRecord
package auj.helpdesk.model;
package auj.helpdesk.model;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class UserRecord {
@Id
private int id;
...
0
votes
0
answers
10
views
Not Recognising parameter when trying to query for more than 1 row jdbctemplate
When executing this SQL statement it will return more than 1 row. However I am getting an error when I try to run this. On the second line , when I hover over the second 'userid' I get this error '...
2
votes
1
answer
57
views
PDF generation fails with large number of records
I am using itext 7 pdf to generate PDF from jdbc query . It works fine for 4000 records but once we inserted 17000 records in the table, I started getting Java Out of Memory space . I am getting all ...
-1
votes
1
answer
140
views
Spring's JdbcTemplate with IN Clause Query
I'm having a trouble using Jdbctemplate's query method while passing the variable QUERY as a query parameter. The following example takes ids as a single parameter and not an array. What's wrong with ...
1
vote
1
answer
52
views
Create Multipe Jdbctemplate at runtime pointing to diffrent databases in runtime
Spring boot Is there any way to create Jdbctemplate at runtime pointing to the different MySQL databases?
Runtime I do have all the required information.
The database structure is the same for all the ...
0
votes
1
answer
164
views
Executing a function in PostgreSQL produces an error it does not exist, but it does exist
When I am trying to call a DB function to get the count in Spring, it will complain:
function xyz.get_search_count_f(integer, character varying, character
varying, bytea, bytea ) does not exist
In ...