Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ Builder setCredentials(Credentials credentials) {
return this;
}

Builder setStatementExecutorType(StatementExecutorType statementExecutorType) {
/**
* Sets the executor type to use for connections. See {@link StatementExecutorType} for more
* information on what the different options mean.
*/
public Builder setStatementExecutorType(StatementExecutorType statementExecutorType) {
this.statementExecutorType = statementExecutorType;
return this;
}
Expand Down Expand Up @@ -920,7 +924,11 @@ CredentialsProvider getCredentialsProvider() {
return getInitialConnectionPropertyValue(CREDENTIALS_PROVIDER);
}

StatementExecutorType getStatementExecutorType() {
/**
* Returns the executor type that is used by connections that are created from this {@link
* ConnectionOptions} instance.
*/
public StatementExecutorType getStatementExecutorType() {
return this.statementExecutorType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,23 @@ private static ListeningExecutorService createExecutorService(StatementExecutorT
*/
private final List<StatementExecutionInterceptor> interceptors;

enum StatementExecutorType {
/** The executor type that is used for statements that are executed on a connection. */
public enum StatementExecutorType {
/**
* Use a platform thread per connection. This allows async execution of statements, but costs
* more resources than the other options.
*/
PLATFORM_THREAD,
/**
* Use a virtual thread per connection. This allows async execution of statements. Virtual
* threads are only supported on Java 21 and higher.
*/
VIRTUAL_THREAD,
/**
* Use the calling thread for execution. This does not support async execution of statements.
* This option is used by drivers that do not support async execution, such as JDBC and
* PGAdapter.
*/
DIRECT_EXECUTOR,
}

Expand Down
Loading