Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import org.jooq.DSLContext;
  2. import org.jooq.Record;
  3. import org.jooq.Result;
  4. import org.jooq.SQLDialect;
  5. import org.jooq.impl.DSL;
  6.  
  7. import java.sql.Connection;
  8. import java.sql.DriverManager;
  9.  
  10. import static example.jooq.Tables.AUTHOR;
  11.  
  12.  
  13. public class Main {
  14. public static void main(final String[] args) {
  15. final String userName = "";
  16. final String password = "";
  17. final String url = "jdbc:sqlite:library.db";
  18.  
  19. try (Connection conn = DriverManager
  20. .getConnection(url, userName, password);
  21. final DSLContext create = DSL.using(conn, SQLDialect.MYSQL)) {
  22. final Result<Record> result = create.select().from(AUTHOR).fetch();
  23.  
  24. for (final Record r : result) {
  25. final Integer id = r.getValue(AUTHOR.ID);
  26. final String firstName = r.getValue(AUTHOR.FIRST_NAME);
  27. final String lastName = r.getValue(AUTHOR.LAST_NAME);
  28.  
  29. System.out.println(
  30. "ID: " + id + " first name: " + firstName + " last name: " + lastName);
  31. }
  32. } catch (final Exception e) {
  33. e.printStackTrace();
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement