Added contentType:varchar field in db

This commit is contained in:
Rahul Rudragoudar 2019-03-07 13:02:41 +05:30
parent 4589c3bbb0
commit cddb143cf7

View File

@ -18,8 +18,8 @@ import scala.Array
class Captcha { class Captcha {
val con: Connection = DriverManager.getConnection("jdbc:h2:./captcha", "sa", "") val con: Connection = DriverManager.getConnection("jdbc:h2:./captcha", "sa", "")
val stmt: Statement = con.createStatement() val stmt: Statement = con.createStatement()
stmt.execute("CREATE TABLE IF NOT EXISTS challenge(token varchar, id varchar, secret varchar, provider varchar, image blob)") stmt.execute("CREATE TABLE IF NOT EXISTS challenge(token varchar, id varchar, secret varchar, provider varchar, contentType varchar, image blob)")
val insertPstmt: PreparedStatement = con.prepareStatement("INSERT INTO challenge(token, id, secret, provider, image) VALUES (?, ?, ?, ?, ?)") val insertPstmt: PreparedStatement = con.prepareStatement("INSERT INTO challenge(token, id, secret, provider, contentType, image) VALUES (?, ?, ?, ?, ?, ?)")
val selectPstmt: PreparedStatement = con.prepareStatement("SELECT secret, provider FROM challenge WHERE token = ?") val selectPstmt: PreparedStatement = con.prepareStatement("SELECT secret, provider FROM challenge WHERE token = ?")
val imagePstmt: PreparedStatement = con.prepareStatement("SELECT image FROM challenge WHERE token = ?") val imagePstmt: PreparedStatement = con.prepareStatement("SELECT image FROM challenge WHERE token = ?")
@ -48,7 +48,8 @@ class Captcha {
insertPstmt.setString(2, provider.getId) insertPstmt.setString(2, provider.getId)
insertPstmt.setString(3, challenge.secret) insertPstmt.setString(3, challenge.secret)
insertPstmt.setString(4, providerMap) insertPstmt.setString(4, providerMap)
insertPstmt.setBlob(5, blob) insertPstmt.setString(5, challenge.contentType)
insertPstmt.setBlob(6, blob)
insertPstmt.executeUpdate() insertPstmt.executeUpdate()
id id
} }
@ -65,7 +66,8 @@ class Captcha {
insertPstmt.setString(2, provider.getId) insertPstmt.setString(2, provider.getId)
insertPstmt.setString(3, challenge.secret) insertPstmt.setString(3, challenge.secret)
insertPstmt.setString(4, providerMap) insertPstmt.setString(4, providerMap)
insertPstmt.setBlob(5, blob) insertPstmt.setString(5, challenge.contentType)
insertPstmt.setBlob(6, blob)
insertPstmt.executeUpdate() insertPstmt.executeUpdate()
} }
} }