I'm writing a program that uses Oracle as a database.
I want to change the default fetch size for SQLs for performance, without code modification.
The program uses SQL in various places, so I want to avoid inserting setFetchSize()
before every Statement.executeQuery()
.
With PostgreSQL or MySQL, you can change the default fetch size with the JDBC URL parameter defaultRowFetchSize
. You can set defaultRowFetchSize=100
to improve the performance of DB access.
However, I couldn't find the equivalent for the Oracle JDBC driver.
Is there any way to set the default fetch size for the Oracle JDBC driver without code modification?
This program accesses Oracle through DataSource
. I can change the JDBC URL. I can also change system properties or environment variables without code modification.
The current implementation doesn't use setFetchSize()
or Properties
to set the default fetch size (it doesn't set any properties to call Statement.executeQuery()
).
Yes. You can specify a defaultRowPrefetch
property.
java.util.Properties info = new java.util.Properties();
info.put ("user", userName);
info.put ("password", passWord);
info.put ("defaultRowPrefetch", "15");
getConnection ("jdbc:oracle:thin:@", info);