Created
June 30, 2012 01:00
-
-
Save takezoe/3021636 to your computer and use it in GitHub Desktop.
Simple wrapper for JDBC API in Scala
This file contains hidden or 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
import jp.sf.amateras.scala.util.Imports._ | |
using(DriverManager.getConnection("")){ implicit conn => | |
withTransaction { conn => | |
// update | |
val rows = conn.execute( | |
"INSERT INTO USER_INFO (USER_ID, USER_NAME) VALUES (?, ?)", | |
1, "takezoe") | |
// select | |
val userList: List[(Int, String)] = conn.select( | |
"SELECT * FROM USER_INFO WHERE USER_ID = ? ", 1){ rs => | |
(rs.getInt("USER_ID"), rs.getString("USER_NAME")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example of scala-utils's JDBC wrapper. It simplifies JDBC programming in Scala!