3 date: 2019-09-27T18:51:08+02:00
6 parent: Persistence APIs
13 The `javax.sql` based implementation of `YoSQL` to access your database. It does not require any dependencies outside from standard JDK classes exposed by the [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity) API. The available configuration is listed split into multiple pages which are listed at the bottom of this page.
17 In order to use the JDBC API in generated code, set the `daoApi` option to `JDBC`. Further configuration can be performed using the dedicated `jdbc` section.
21 In order to use `YoSQL` together with [Maven](https://maven.apache.org/), take a look at the tooling [documentation
22 for Maven](/tooling/maven/).
24 {{< maven/persistence/jdbc/index >}}
28 In order to use `YoSQL` together with [Gradle](https://gradle.org/), take a look at the tooling [documentation for Gradle](/tooling/gradle/).
40 ... jdbc configuration
47 In order to use `YoSQL` together with [Bazel](https://bazel.build/), take a look at the tooling [documentation for
48 Bazel](/tooling/bazel/).
52 In order to use YoSQL on the command line, take a look at the tooling [documentation for CLI](/tooling/cli/).
55 $ yosql --apis-dao-api=JDBC
58 The shorter form is available as well:
61 $ yosql --dao-api=JDBC
66 The JDBC API offers no built-in object mapping mechanism. In order to use high level types of your domain, use a converter to map results to your types.
70 -- converter: my.own.UserConverter
75 You can either specify the fully-qualified name of the converter or use its alias. The result type is read from the converter configuration as well. This in turn changes the generated code into this:
78 // uses "User" as type argument for all return types
79 List<User> findUsers()
80 Stream<User> findUsersStreamEager()
81 Stream<User> findUsersStreamLazy()
82 Flowable<User> findUsersFlow()
85 `my.own.UserConverter` could look like this:
90 import java.sql.ResultSet;
91 import java.sql.SQLException;
94 import my.own.persistence.util.ResultState;
96 public class UserConverter {
98 public final User asUserType(final ResultState result) throws SQLException {
99 final ResultSet resultSet = result.getResultSet();
100 final User pojo = new User();
101 pojo.setId(resultSet.getInt("id"));
102 pojo.setName(resultSet.getString("name"));