Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import oracle.jdbc.pool.OracleDataSource
- object Conn {
- def main(args: Array[String]) {
- if (args.length != 5) {
- println("Arguments hostname serviceName port username password")
- System.exit(1)
- }
- val ods = new OracleDataSource()
- ods.setUser(args(3))
- ods.setPassword(args(4))
- ods.setURL("jdbc:oracle:thin:@" + args(0) + ":" + args(1) + "/" + args(2))
- val con = ods.getConnection()
- con.setAutoCommit(false)
- println("Connected")
- val sql = "update emp set sal = sal * 1.1 where empno=:empno"
- val s2 = con.prepareStatement(sql)
- val empno = 7369
- s2.setInt(1, empno)
- s2.execute()
- con.commit()
- println("Committed")
- s2.close()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement