Created
August 21, 2017 07:58
-
-
Save ps06756/ced9ea8213b9663d9ba8ec104a12f6cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jooq; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.SQLException; | |
import org.jooq.SQLDialect; | |
import org.jooq.DSLContext; | |
import org.jooq.Configuration; | |
import org.jooq.impl.DefaultConfiguration; | |
import org.jooq.impl.DSL; | |
import static com.jooqGenerated.Tables.*; | |
import org.jooq.Record; | |
import org.jooq.Result; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
Class.forName("com.mysql.cj.jdbc.Driver").newInstance(); | |
try ( Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/jooq?" + | |
"user=root&password=root");) { | |
Configuration config = new DefaultConfiguration(); | |
config.set(connection); | |
config.set(SQLDialect.MYSQL); | |
DSLContext create = DSL.using(config); | |
System.out.println(create.select(STUDENT.STUDENTNAME).from(STUDENT).where(STUDENT.STUDENTID.eq(1)).fetchOne(STUDENT.STUDENTNAME)); | |
} | |
} | |
catch(Exception ex) { | |
ex.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment