Skip to content

Instantly share code, notes, and snippets.

@keirlawson
Last active October 6, 2018 10:17
Show Gist options
  • Save keirlawson/5b4d1f5dabacb9d5c564263b22313665 to your computer and use it in GitHub Desktop.
Save keirlawson/5b4d1f5dabacb9d5c564263b22313665 to your computer and use it in GitHub Desktop.
case class BigString(value: String) extends AnyVal
def getClob(rs: ResultSet, i: Int): BigString = {
val clob = rs.getClob(i)
val str = Source.fromInputStream(clob.getAsciiStream).mkString
BigString(str)
}
def setClob(ps: PreparedStatement, i: Int, bs: BigString): Unit = {
val reader = new StringReader(bs.value)
ps.setClob(i, reader)
}
def updateClob(rs: ResultSet, i: Int, bs: BigString): Unit = {
val reader = new StringReader(bs.value)
rs.updateClob(i, reader)
}
implicit val ClobMeta: Meta[BigString] = Meta.advanced(NonEmptyList.of(JdbcType.Clob), NonEmptyList.of("CLOB"), getClob, setClob, updateClob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment