createConnection
Controls whether the generated code should create/open connection itself or use a given connection.
A method either takes a connection from the repository’s DataSource and closes it when it
is done, or takes a java.sql.Connection as its first parameter and leaves it open for
whoever passed it in.
With generateConnectionOverloads left on — it is on by default — you get both and this setting decides nothing you have to think about. It matters when you turn overloads off and want one shape rather than the other.
Configuration Options
Option: ’true'
The default. The method opens a connection and closes it:
public final class SomeRepository {
public List<Tenant> findTenants() {
try (final var connection = dataSource.getConnection()) {
// ... rest of generated code
}
}
}
Option: ‘false’
The connection comes from the caller, so the statement can join work already in progress:
public final class SomeRepository {
public List<Tenant> findTenants(final Connection connection) {
// ... rest of generated code
}
}
Related Options
Also in this group: allowedCallPrefixes , allowedReadPrefixes , allowedWritePrefixes , basePackageName , catchAndRethrow , executeBatch , executeOnce , generateConnectionOverloads , generateInterfaces , injectConverters , throwOnMultipleResults , validateMethodNamePrefixes , writesReturnUpdateCount .
Tooling
Ant
In order to use YoSQL together with Ant
, take a look at the tooling documentation for Ant
.
Bazel
In order to use YoSQL together with Bazel
, take a look at the tooling documentation for Bazel
.
CLI
In order to use YoSQL on the command line, take a look at the tooling documentation for CLI
.
yosql generate --repositories-create-connection=configValue
Gradle
In order to use YoSQL together with Gradle
, take a look at the tooling documentation for Gradle
. The createConnection setting can be configured using Gradle in Kotlin syntax like this:
plugins {
java
id("wtf.metio.yosql") version "2026.8.8"
}
yosql {
repositories {
createConnection.set(configValue)
}
}
or in Groovy syntax like this:
plugins {
id "java"
id "wtf.metio.yosql" version "2026.8.8"
}
yosql {
repositories {
createConnection = configValue
}
}
Maven
In order to use YoSQL together with Maven
, take a look at the tooling documentation for Maven
. The createConnection setting can be configured using Maven like this:
<build>
<plugins>
<plugin>
<groupId>wtf.metio.yosql.tooling</groupId>
<artifactId>yosql-tooling-maven</artifactId>
<version>2026.8.8</version>
<configuration>
<repositories>
<createConnection>configValue</createConnection>
</repositories>
</configuration>
</plugin>
</plugins>
</build>