How to set the default fetch size when jOOQ gets an OOM error when fetching a huge result set

If jOOQ tries to fetch a huge result set in a stream, but you get ʻOutOfMemoryError`, the fetch size is probably infinite (in the case of PostgreSQL driver). Let's make the XML file of jOOQ used as the default setting value of fetch size of jOOQ directly under the root of the classpath.

(Refer to ʻorg.jooq.conf.SettingsTools` for detailed processing)

src/main/resources/jooq-settings.xml


<?xml version="1.0" ?>

<settings
        xmlns="http://www.jooq.org/xsd/jooq-runtime-3.11.2.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!--Please specify an appropriate size.-->
    <fetchSize>1000</fetchSize>

</settings>

In addition, in order to unmarshall the above XML to JavaBeans according to the above settings, the following dependency is required separately. Let's add it.

build.gradle


    //Depending on the case, the version specification may differ, so please search for an appropriate value.

    runtime('javax.activation:activation:1.1.1')
    runtime("com.sun.xml.bind:jaxb-impl:...")
    runtime("com.sun.xml.bind:jaxb-core:...")

Same for Spring Boot

Even if you use spring-boot-starter-jooq in SpringBoot, there seems to be no way to implement the same settings as above in ʻapplication.properties` etc., so let's give up and put the XML file.

Other methods (for PostgreSQL)

I had a colleague teach me.

It seems that the following character string should be added to PostgreSQL JDBC URL.

&defaultRowFetchSize=1000

Recommended Posts

How to set the default fetch size when jOOQ gets an OOM error when fetching a huge result set
An error occurred when executing a function from MyBatis with the OUT parameter set to CURSOR in PostgreSQL.
How to set chrony when the time shifts in CentOS7
A validation error occurred when saving to the intermediate table.
[Java] Adding an element to the Collection causes a compile error
How to output the value when there is an array in the array
[jOOQ] How to CASE WHEN in the WHERE / AND / OR clause
How to solve the unknown error when using slf4j in Java
How to set an image in the drawable Left / Right of a button using an icon font (Iconics)
What to do and how to install when an error occurs in DXRuby 1.4.7
How to display error messages and success messages when registering as a user
I want to display an error message when registering in the database
[Swift] How to set an image in the background without using UIImageView.
How to reference a column when overriding the column name method in ActiveRecord
When registering a new user, I got an error called ActiveRecord :: NotNullViolation and how to deal with it.
What to do if you get an "A server is already running." Error when you try to start the rails server
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
When introducing JOOQ to Spring boot, a story that was dealt with because an error occurred around Liquibase