Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jooq.DSLContext;
- import org.jooq.Record;
- import org.jooq.Result;
- import org.jooq.SQLDialect;
- import org.jooq.impl.DSL;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import static example.jooq.Tables.AUTHOR;
- public class Main {
- public static void main(final String[] args) {
- final String userName = "";
- final String password = "";
- final String url = "jdbc:sqlite:library.db";
- try (Connection conn = DriverManager
- .getConnection(url, userName, password);
- final DSLContext create = DSL.using(conn, SQLDialect.MYSQL)) {
- final Result<Record> result = create.select().from(AUTHOR).fetch();
- for (final Record r : result) {
- final Integer id = r.getValue(AUTHOR.ID);
- final String firstName = r.getValue(AUTHOR.FIRST_NAME);
- final String lastName = r.getValue(AUTHOR.LAST_NAME);
- System.out.println(
- "ID: " + id + " first name: " + firstName + " last name: " + lastName);
- }
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement