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
Class.forName(JDBC_DRIVER) | |
Connection conn = DriverManager.getConnection(creds.url, creds.userName, creds.password) | |
String updateTableSQL = "update Book set title=? where id=?" | |
PreparedStatement preparedStatement = conn.prepareStatement(updateTableSQL) | |
preparedStatement.setString(1, title) | |
preparedStatement.setInt(2, id) | |
preparedStatement.executeUpdate() |
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
Class.forName(JDBC_DRIVER) | |
Connection conn = DriverManager.getConnection(url, userName, password) | |
String insertTableSQL = "INSERT INTO BOOK (ID, TITLE, AUTHOR_ID) VALUES (?,?,?)" | |
Map insertTest = [(Book.BOOK.ID): 7, | |
(Book.BOOK.AUTHOR_ID): 1, | |
(Book.BOOK.TITLE): "Coding in JDBC"] | |
PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL) | |
preparedStatement.setInt(1, insertTest[(Book.BOOK.ID)]) |
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
select b.id, b.title, a.first_name, a.last_name from | |
Book b inner join | |
Author a on | |
b.author_id = a.id; |
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
String sql = "””INSERT INTO AUTHOR (ID, FIRST_NAME, LAST_NAME) | |
VALUES (:id, :firstName, :lastName)"”” | |
Map parameters = [id: 1337, firstName: “Pauly”, lastName: "McCoy"] | |
// jdbcTemplate is an autowired property | |
jdbcTemplate.update(sql, parameters) |
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
create.update(Book.BOOK) | |
.set(Book.BOOK.TITLE, "A Brief Introduction to JOOQ") | |
.where(Book.BOOK.ID.equal(2)) | |
.execute() |
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
Result<Record> result = create.select().from(Book.BOOK).fetch() |
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
create.insertInto(Book.BOOK) | |
.set(Book.BOOK.ID, 5) | |
.set(Book.BOOK.AUTHOR_ID, 1) | |
.set(Book.BOOK.TITLE, "The Idiot's Guide to Programming") | |
.execute() |
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
@Lob | |
@Column(name = "DATA") | |
private String data; |
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
insert into myclobs (data, date_created) values (‘[{ | |
"_id": "556e52fc21aa6202ee1aac18", | |
"index": 0, | |
"guid": "dd60b0a8-2bb8-4dae-83b4-1940b2e47f9c", | |
"isActive": false, | |
"balance": "$3,616.96", | |
"picture": "http://placehold.it/32x32", | |
"age": 40, | |
"eyeColor": "blue", | |
"name": "Mayra Stevenson", |
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
SELECT data.eyeColor FROM myclobs; |