Questions tagged [spring-jdbc]

1

votes
2

answer
43

Views

How to programmatically discover the JPA implementation and SQL dialect being used by Spring Boot?

I know it is possible to change the JPA implementation in use by Spring Boot, the default is to use Hibernate, but it's also possible to user others, like EclipseLink. It is possible to find, at application runtime, which JPA implementation is being used, and also discover which SQL dialect is curre...
André Shevantes
1

votes
1

answer
98

Views

Select on Northwind database using JPA and JDBC Template

I would like to perform select statement on Northwind database like this bellow. select distinct b.*, a.CategoryName from Categories a inner join Products b on a.CategoryID = b.CategoryID where b.Discontinued = 'N' order by b.ProductName; I have two problems regarding this operation : I have crea...
jocom
1

votes
0

answer
225

Views

declaredParameters versus addDeclaredParameter SimpleJdbcCall

So I'm working with an Oracle database and a function as opposed to a stored procedure. I figured this was no big deal and carried on as I had with all my previous DAO's created for the stored procedures. This did not work. The difference is demonstrated below. Here's the function setup that works f...
Mike
1

votes
1

answer
264

Views

How best to handle Constraint Violations in Spring JDBC

What is considered the best/most correct way to handle a Constraint Violation in Spring JDBC? As a real example. I've got a users table that contains, amongst other things, columns of url_slug and email. Both of these are UNIQUE. When creating a new record, or updating an existing record, if I try t...
Graham
1

votes
0

answer
353

Views

Save entity with java.time.Instant property using NamedParameterJdbcTemplate with postgres driver

I am having issues saving my entity that has a Instant value using the NamedJdbcTemplate. I receive the exception listed below and I am trying to determine the best way to resolve this. Please advise. Can't infer the SQL type to use for an instance of java.time.Instant. Use setObject() with an expli...
Jesse Nelson
1

votes
0

answer
640

Views

Getting Error : SQLErrorCodes loaded: Spring jdbc connection

I am getting below error when I am trying to insert row in database and also while calling prepared statement: INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] 07:05:53,727 INFO SQLErrorCodesFactory:126 -...
prachik
1

votes
1

answer
421

Views

Does BasicDataSource use connection pooling by default?

I use the following to connect to DB (spring config) Does this internally use any connection pooling? If yes what is the size?
TomJava
1

votes
0

answer
52

Views

jMock test case for Spring JDBC template operations

I am using Spring and JDBC to insert into an Oracle Database using NamedParameterJdbcOperations. I got an error when I tried to write a test case for this operation using jMock and in-memory h2 database CREATE TABLE DIM_ATTRIBUTE ( ATTRIBUTE_ID VARCHAR2(45) NOT NUL...
TechEnthu
1

votes
0

answer
275

Views

SimpleJdbcCall always omits the first parameter in function calls

I'm trying to use the SimpleJdbcCall class to call functions in an Oracle package, but every call ignores the first input parameter. My code looks like this: SimpleJdbcCall call = new SimpleJdbcCall(jdbcTemplate.getJdbcTemplate()) .withSchemaName('MY_SCHEMA') .withCatalogName('MY_PACKAGE') .withFunc...
pablo
1

votes
1

answer
39

Views

Spring Poller running from multiple app servers

We are using spring poller in our application to poll the data from mySQL DB and send to a third party. The functionality is as such working but when we moved to PRODUCTION since we have mutiple appservers , the job is running from all servers and we need this to be run in all servers to address th...
kana
1

votes
0

answer
236

Views

How to insert more than 2000 char in Oracle column of type Varchar2(4000 char) from Java Code

I am trying to insert 2000 char(ASCII char should take 1 byte only) into column of type Varchar2(4000 char) using Spring JDBC Template. But I am always getting the following error java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column. I have tried using the bel...
Ankur Singh
1

votes
0

answer
32

Views

Non-primary embedded database schema not being initiliazed

I'm currently working on a Spring Boot (1.5.10.RELEASE) application that uses 2 embedded databases. This two databases are defined equally but one's defined on the application itself and one's defined on a custom autoconfiguration class that's on an imported JAR; yet only the one flagged as @Primary...
gnzlrm
1

votes
0

answer
58

Views

Insert 1000s of records with relationship and ignore duplicates using JDBC & MySQL

I am refactoring some code that was horribly inefficient but am still seeing huge load on both my MySQL and Java servers. We have an endpoint that allows a user to upload a CSV file containing contacts with a first name, last name, phone number, and email address. The phone number and email address...
Gremash
1

votes
0

answer
771

Views

Spring Boot “Cannot add foreign key constraint”

I have a spring boot rest service with the following model classes - Report class - @Entity @Table (name = 'report') @EntityListeners(AuditingEntityListener.class) public class Report { @Id @Column (name = 'id') @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(name = 'from_u...
Nalin Kamboj
1

votes
1

answer
285

Views

Methods of JedisConnectionFactory is deprecated. Which XML configuations to used in Spring Batch?

I am developing an utility in Spring batch will read data from Mysql/Oracle and write it to the Redis database. Currently we still using Spring Batch XML based configurations (we still like the XML based - gives little control to us :)) When I configured the following I see most of the methods are d...
Jeff Cook
1

votes
1

answer
31

Views

int-jdbc:inbound-channel-adapter channel depth

if the configured channel in int-jdbc:inbound-channel-adapter is full,after that polling happens or not ? Can I use a queue channel in int-jdbc:inbound-channel-adapter? My requirement is that if the channel is full,no DB call should make ,until channel is free.
1

votes
0

answer
2.1k

Views

Could not open JDBC Connection for transaction

I would like to report a configuration problem that seems strange to me. Here's the application context configuration file I'm using classpath:jdbc.properties ** ** But when run the converting action, i have this error: Problems with processing file /***.zip org.springframework.transaction.CannotCre...
Archi
1

votes
0

answer
310

Views

Spring 5 replacement for CommonsDbcpNativeJdbcExtractor

enter link description hereI have a project configured with spring boot 1.5, I'm updating the app to spring boot 2.XXX, the app beans are configured in an xml file, part of this file contains: As you can see, there is a JMS listener connected to an Oracle queue. The problem comes when I update to sp...
Eduardo
1

votes
0

answer
67

Views

Oracle-17132 when passing a Char from storedFunction

I'm facing an issue with my StoredFunction. It looks trivial, but I don't see a way to fix it. Oracle DB contains a function with following signature and some simple body FUNCTION MY_FUNC (CARD_NUM_IN in char, CARD_ID number default null) return number; I execute call to the function as follows: S...
Ermintar
1

votes
1

answer
917

Views

How to setup Spring JDBC Connection Pooling with Spring Boot?

Am using Spring Boot 1.5.4 with Spring JDBC. Have a Spring Boot Microservice which uses Spring JDBC has the following issue when trying to conduct an HTTP PUT (after a bunch of users try conducting an HTTP PUT) which trickles to this Spring JDBC call: 2018-10-10 19:40:02 [http-nio-8081-exec-4] ERROR...
PacificNW_Lover
1

votes
1

answer
182

Views

jdbcTemplate.update freezes

I'm using a Spring JdbcTemplate without a 'transactionManager' since I have mostly select to do. When I try to call select queries from JUnit, it works, but when I try to call an 'update', it freezes the test (no connection timeout, nothing, just waiting). I've seen examples of jdbcTemplates insert/...
Tristan
1

votes
1

answer
511

Views

Postgresql JDBC SSL

We have a remote PostgreSQL DB server which requires SSL certs to be provided to connect to it. I have the following certs with me. root.pem intermediate.pem private-chain.pem public-chain.pem certificate.cer certificate.key And I am able to connect to the remote database using psql as psql 'port=54...
abisheksampath
1

votes
1

answer
484

Views

Error Executing DDL via JDBC statement in Spring Boot 2, Hibernate, PostgreSQL

I wanted to connect to Heroku cloud with my Spring boot 2.0.6 application using PostgreSQL but I'm getting an exception. It seemed to work fine in Spring boot 1, so it might be a Spring boot 2 problem. I've tried modifying my applicaton.properties in different ways but none of them succeeded. My log...
Alexander Phoenix
1

votes
0

answer
126

Views

How to use sql with optional query params in JdbcTemplate?

I have the following sql template that I want to use with JdbcTemplate: select * from table1 where (@param1 is null or col1 = @param1) and (@param2 is null or col2 = @param2) What is special here is that 'param1' and 'param2' can be used as optional params to restrict the query. Problem: how can I n...
membersound
1

votes
1

answer
884

Views

Spring boot “Hikari Pool Shutdown” early error

ERROR: 2018-11-12 18:25:31.221 INFO 3028 --- [ Thread-3] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2018-11-12 18:25:31.223 INFO 3028 --- [ Thread-3] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. Why does this error...
Shale
1

votes
0

answer
38

Views

Creating multiple object with one response using Spring FrameWork

This is my first time using Spring to add and get data from a database. I have successfully established connection with my database and can add Plants with only id and plantName but now for the part that I do not understand. How can I create an RowMapper or something else that would work with a loo...
Richard
1

votes
1

answer
282

Views

Overriding timeout for database connection in properties file

I was wondering if there is a specific way to override database connection timeout in the properties file in my Java web project? I am using Hibernate, Spring, and MySQL DB. I have tried several different property fields and reduced the timeout time to 1 millsecond, yet the connection is still compl...
Navid Galt
1

votes
0

answer
25

Views

Camel component not see datasource

Here my java config(Spring 3.2.4, camel 2.13.4), which create camelContext and dataSource @Configuration @ComponentScan(basePackages = 'some.package.here') public class BeansConfig { @Bean public DataSource dataSource(){ DataSource dataSource = new DriverManagerDataSource(); ((DriverManagerDataSourc...
Anatoly Utkin
1

votes
1

answer
15

Views

'Parameter index out of range (2 > number of parameters, which is 1).' for a two parameter statement

I'm following this tutorial to learn about Spring JdbcTemplate, and it has the following example which works fine: public void deleteDog(String name, Long id) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.update('DELETE FROM dog WHERE name='' + name + '' AND id=' + id); }...
Lewis Cawthorne
1

votes
2

answer
25

Views

How to get the entities defined within the java spring boot application to be reflected within a database without the use of CrudRepository

I am building a web application using spring boot and mySQL. I have been following a video guide series to the letter but the author did not show how he set up the database. This is the video I am stuck replicating the results from: https://www.youtube.com/watch?v=KBfiEL-FomQ&index=7&list=PL2OrQJM8z...
Faisal
1

votes
0

answer
56

Views

Saved entity in a Spring Kafka Listener is not rollbacked on a transactional test

I have a @KafkaListener which saves a new entity using Spring Data JDBC Repository. The saved entity is not rollbacked on a test annotated with @Transactional @Service public class KafkaConsumer { private final EntityRepository entityRepository; private CountDownLatch countDownLatch; public KafkaCon...
yraydhitya
1

votes
1

answer
33

Views

TKProf (Oracle event 10046) on Spring Boot/JDBC

I'm trying to start oracle tracing through invoking direct JDBC calls. I'm obtaining my connection from Spring (boot/jdbc). Then I run the TKProf commands through statements... execute the query and print to the log. The 3 statements below are returning false. If I use this same statements through I...
Chuck
1

votes
0

answer
31

Views

How to set properties of Tomcat JDBC Pool when using Spring Cloud Connector config?

I want to configure the properties of the Tomcat JDBC Pool with custom parameter values. The pool is bootstrapped by the spring-cloud (Spring Cloud Connector) environment (Cloud Foundry) and connected to a PostgreSQL database. In particular, I want to set the minIdle, maxIdle and initialSize propert...
EagleRainbow
1

votes
1

answer
29

Views

How to get full sql script with replaced wild cards in jdbcTemplate?

I have following code public class Foo{ private final NamedParameterJdbcTemplate nJdbcTemplate; public void bar(....){ String query = 'INSERT INTO .... .... nJdbcTemplate.batchUpdate(query, mapSqlParameterSourcesArray); } } I want to get full , valid insert SQL script to insert it into another datab...
gstackoverflow
1

votes
2

answer
84

Views

Spring Session with JDBC | Principal is null

I use Spring Session with JDBC and Mysql. The Spring Security Login is successfully but the principal name is null. Does anyone have an idea, whats the mistake? Files: application.yaml: session: store-type: jdbc jdbc: initialize-schema: always table-name: SPRING_SESSION Configuration: @EnableGlobalM...
Tom
1

votes
0

answer
12

Views

Oracle Custom User Defined Type ReadSql Stream in a type safe method

Hi I use simplejdbccall and storedprocedure to make database call.In my stored procedure I have some userdefinedtypes in my output.I can read this output class with help of SQLData and set my own java object model. Myproblem is when I want to read SqlStream ,all properties must be same order in data...
Bilgehan
1

votes
0

answer
22

Views

Unable to execute Spring JDBC Project from JAR

I'm able to execute the project in Eclipse, but when I export it as a jar (Eclipse Option : Extract the required libraries in jar) I'm getting following exception Exception in thread 'main' org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to loc...
Omkar Dhorge
1

votes
2

answer
4.4k

Views

Reading a BLOB using JDBC Spring without a result set

I have an Oracle stored procedure that returns a BLOB in an output parameter: PROCEDURE GET_IMAGE_DATA(i_image_type IN NUMBER, o_image_data OUT BLOB) IS BEGIN SELECT IMAGE_DATA INTO o_image_data FROM IMAGES WHERE IMAGE_TYPE = i_image_type; END GET_IMAGE_DATA; I want to use JDBC Spring to read thi...
wadesworld
1

votes
1

answer
134

Views

Send Multiple Data to DB in Spring

I have this scenario in my Spring MVC Apps. User has to choose what hobbies he/she likes. He can choose at least one or many hobbies. My problem is this, If I need to save the list of hobbies into my DB, I am thinking of sending the list of hobbies that my user has chosen, delimited by a comma sep...
Mark Estrada
1

votes
1

answer
227

Views

Spring JDBCTemplate on Seam-based app

When manual SQL is required (JDBC API with pre-written queries), what is the best approach in a Seam-based application ? In Seam Documentation, use of Spring bridge to inject a Spring JDBCTemplate is defined as the most complex to setup, but the easiest for development. Do you agree with that ?
Benoît Guérout

View additional questions