Last active
September 27, 2015 03:33
-
-
Save brunkb/7b2b505b610f5d0fba59 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
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)]) | |
preparedStatement.setString(2, insertTest[(Book.BOOK.TITLE)]) | |
preparedStatement.setInt(3, insertTest[(Book.BOOK.AUTHOR_ID)]) | |
preparedStatement .executeUpdate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment