Spring data and oracle slow data load - java

I'm developing an Spring-boot app with spring-data and oracle database. I have a couple of pretty simple tables but load of the data is so slow.
For example, loading 2000 rows from table that only have 3 columns (texts) lasts almost 25 seconds. I was using the spring data before but not with spring boot and it was not that slow. I have only one resource file application.properties and here it is.
spring.datasource.url = jdbc:oracle:thin:#1.2.3.4:1521:abcd
spring.datasource.username = user
spring.datasource.password = ____
spring.datasource.driverClassName = oracle.jdbc.driver.OracleDriver
spring.datasource.maxActive=15
spring.datasource.initialSize=5
spring.datasource.validationQuery=select 1
spring.datasource.removeAbandoned=false
spring.datasource.testOnBorrow=true
spring.datasource.testOnReturn=true
spring.jpa.database-platform = org.hibernate.dialect.Oracle10gDialect
I've been trying with default repository implementation like findAll() as well as with custom #Query and it is the same.
Do I need some additional configuration? Any ideas?

In the configuration properties, you should use spring.jpa.properties.hibernate.jdbc.fetch_size

Related

H2 console does not show Spring Boot created tables when configuring and using embedded local persistence even though they are there

I have setup H2 as an embedded persistent database ('Embedded (Local) Database' with jdbc:h2:[file:][<path>]<databaseName>) with Spring Boot using Spring Data JPA abstraction, like below
spring.datasource.url=jdbc:h2:file:/home/data/embeddeddb;CACHE_SIZE=${spring.datasource.cache.size:131072}
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=someusr
spring.datasource.password=somepwd
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=none
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
#spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=true
I placed the schema.sql under my project resources and see that i am able to perform CRUD operations via the CrudRepository. I also enabled h2 console via properties as shown above.
But when i connect to the database from the h2 console using the same URL i specified (above), it does not show me the tables i have created or the configured cache size.
This even though i can use #Query methods in my CrudRepository to see that they are there.
I am not sure what i am missing here, can someone throw light on this?
Thanks

Spring Boot: how to connect to external h2 database

I have created one Spring boot application and I am not using in-memory H2 database, instead I have installed exe for H2 database and using it externally. Now I want to connect my Spring boot app with this external H2 database. I have added the dependencies, I have added all the required properties in application.properties file (you can see below). Also I have created one Entity class having #Entity annotation. But when I am trying to connect with the database it is connecting even with different URL and username and I cannot see my Entity class table over there. So where am I doing a mistake and what are the things which I have missed, please address me on this.
For your information, my Spring boot app is running on port - 8080 and H2 database is running on 8082
spring.h2.driverClassName = org.h2.Driver
spring.h2.url = jdbc:h2:file:~/test2;DB_CLOSE_ON_EXIT=FALSE; AUTO_RECONNECT=TRUE
spring.h2.username = QW
spring.h2.password = root
spring.h2.console.enabled = true
spring.datasource.platform = h2
You can try this
spring.datasource.url=jdbc:h2:tcp://localhost:8082/~/<DB-NAME>
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driverClassName=org.h2.Driver
Give in properties file
# H2
spring.datasource.url=<your value
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
Check this tutorial below link
https://howtodoinjava.com/spring-boot2/h2-database-example/
https://www.baeldung.com/spring-boot-h2-database

Spring 5 constantly losing connection to the DB

I know this question was asked a lot and there is ton of articles about it, but none of the solutions seem to work for me, I'm new to Spring so maybe I'm missing something.
I'm using spring 5.0.6 , spring boot 2.0.0, with hibernate, mysql and Hikari pool.
My app connects successfully and performing succesfull query and then losing connection. Here's related application config:
spring.datasource.url=jdbc:mysql://server/db?useSSL=false
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.testOnBorrow=true
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 20000
spring.datasource.validationQuery = SELECT 1
spring.jpa.show-sql = true
I've also tried setting config specific to hikari, still no luck.
spring.datasource.hikari.connection-timeout=3000
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=1
spring.datasource.hikari.connection-test-query=SELECT 1
Can anyone give a hint?

Spring boot: configure hsqldb datasource to persist data

I am trying to create a spring boot app. I want to persist data using hsql database.
first I did include hsqldb maven dependency and springboot auto-configure is working fine, but after app restart data is lost.
Then I did include following configuration in application.peoprties file
spring.datasource.url = jdbc:hsqldb:file:testdb.script
spring.datasource.username = SA
spring.datasource.password =
#JPA properties
spring.jpa.generate-ddl=true
But data is still not persisted.
What should be configuration for persisting data?
Thanks for helping.
The default for spring.jpa.hibernate.ddl-auto is create-drop if you use an embedded database. Update this in your properties to spring.jpa.hibernate.ddl-auto=validate or none

HSQL DB lost when spring-boot app restarts

I'm using liquibase to initialize my db in my springboot app and it works fine until I restart - the db is re-initialized wiping all the data.
Here are my application properties
# Liquibase
liquibase.change-log=classpath:/db/changelog/iot-db.xml
liquibase.check-change-log-location=true
# Hibernate
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=
entitymanager.packagesToScan=com.whatever
Are there properties which will allow me to create a persistent db instead of an in memory db?
in application.properties, set this property:
spring.jpa.hibernate.ddl-auto = validate
source and more info.

Categories

Resources