Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Scala update scott.emp jdbc

ExaGridDba Nov 26th, 2014 214 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import oracle.jdbc.pool.OracleDataSource
  2.  
  3. object Conn {
  4.  
  5.   def main(args: Array[String]) {
  6.     if (args.length != 5) {
  7.       println("Arguments hostname serviceName port username password")
  8.       System.exit(1)
  9.     }
  10.     val ods = new OracleDataSource()
  11.     ods.setUser(args(3))
  12.     ods.setPassword(args(4))
  13.     ods.setURL("jdbc:oracle:thin:@" + args(0) + ":" + args(1) + "/" + args(2))
  14.     val con = ods.getConnection()
  15.     con.setAutoCommit(false)
  16.     println("Connected")
  17.     val sql = "update emp set sal = sal * 1.1 where empno=:empno"
  18.     val s2 = con.prepareStatement(sql)
  19.     val empno = 7369
  20.     s2.setInt(1, empno)
  21.     s2.execute()
  22.     con.commit()
  23.     println("Committed")
  24.     s2.close()
  25.   }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top