
from openDB import *

scon=protocol+dbName+';create=true'
conn = DriverManager.getConnection(scon, props)
s = conn.createStatement()

try:
  s.execute('drop table '+table) 
except SQLException:
  print 'no need to remove table'

s.execute('create table '+table+'(num int, addr varchar(40))')
s.execute('insert into '+table+' values (1956,\'Webster St.\')')
s.execute('insert into '+table+' values (1910,\'Union St.\')')


s1='update '+table+' set num=?, addr=? where num=?'
ps = conn.prepareStatement(s1)
ps.setInt(1,180)
ps.setString(2, 'Grand Ave.')
ps.setInt(3, 1956)
ps.executeUpdate()
print 'Updated 1956 Webster to 180 Grand'


s.close()
conn.commit()

try: 
 DriverManager.getConnection('jdbc:derby:;shutdown=true')
except SQLException:
 print 'all done'
