package com.hellokoding.jooq;
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 com.hellokoding.jooq.model.Tables.*;
public class Application {
public static void main(String[] args) throws Exception {
String user = System.getProperty("jdbc.user");
String password = System.getProperty("jdbc.password");
String url = System.getProperty("jdbc.url");
String driver = System.getProperty("jdbc.driver");
Class.forName(driver).newInstance();
try (Connection connection = DriverManager.getConnection(url, user, password)) {
DSLContext dslContext = DSL.using(connection, SQLDialect.MYSQL);
Result<Record> result = dslContext.select().from(AUTHOR).fetch();
for (Record r : result) {
Integer id = r.getValue(AUTHOR.ID);
String firstName = r.getValue(AUTHOR.FIRST_NAME);
String lastName = r.getValue(AUTHOR.LAST_NAME);
System.out.println("ID: " + id + " first name: " + firstName + " last name: " + lastName);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
最近下载更多
ningmeng2020 LV2
2020年11月5日
最代码官方 LV168
2020年10月18日
最近浏览更多
dsfgfdhff LV3
2023年7月5日
微信网友_6040315240812544 LV8
2022年10月27日
songyuyu LV4
2021年4月16日
568885778 LV12
2021年4月8日
jpfjpfjpf LV1
2020年12月11日
1798672867 LV21
2020年12月4日
hzl6032 LV2
2020年11月29日
heqian LV17
2020年11月25日
fx763226791 LV11
2020年11月25日
ningmeng2020 LV2
2020年11月5日

