CREATE DATABASE `library`;
USE `library`;
CREATE TABLE `author` (
`id` int NOT NULL,
`first_name` varchar(255) DEFAULT NULL,
`last_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
import org.jooq.*;import org.jooq.conf.ParamType;import org.jooq.conf.Settings;import org.jooq.conf.StatementType;import org.jooq.impl.DSL;
import static library.Tables.*;import static org.jooq.impl.DSL.*;
import java.sql.*;
public class JooqTutorial { public static void main(String[] args) { String username = "root"; String password = "root"; String url = "jdbc:mysql://127.0.0.1:6033/library";
try (Connection conn = DriverManager.getConnection(url, username, password)) { Settings settings = new Settings(); settings.setStatementType(StatementType.STATIC_STATEMENT); settings.setParamType(ParamType.INLINED); DSLContext create = DSL.using(conn, SQLDialect.MYSQL, settings); SelectConditionStep<Record> fred = create.select().from(AUTHOR).where( AUTHOR.FIRST_NAME.eq(inline("fred")) ); Result<Record> result = fred.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.printf("Id:%d %s, %s\n", id, lastName, firstName); } } catch (Exception e) { e.printStackTrace(); } }}
select `library`.`author`.`id`, `library`.`author`.`first_name`, `library`.`author`.`last_name` from `library`.`author` where `library`.`author`.`first_name` = ?
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
SET character_set_results = NULL
SET autocommits=?
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
mysql-connector-java-8.0.7-dmr ( Revision: d33a3ca56530848bebdf75cf48cf8e68e0feef98 )