Last active
September 8, 2015 16:42
-
-
Save wpoosanguansit/51135720c0d4904c2b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object DynamicQuery { | |
val connection = DriverManager.getConnection(url, properties) | |
def dynamicQuery(queries: Seq[(String, String, Int, String)]): Map[(String, String, String, Int), (String, Boolean)] = { | |
val variables = scala.collection.mutable.Map[(String, String, String, Int), (String, Boolean)]() | |
queries.foreach { case (objectName, typeCode, index, query) => | |
val stmt = connection.createStatement | |
val rs = stmt.executeQuery(query) | |
if (rs.next) { | |
for (i <- 1 to rsm.getColumnCount) { | |
val table = rsm.getTableName(i) | |
val columnName = rsm.getColumnName(i) | |
val columnType = rsm.getColumnType(i) | |
val json = table == "T_TARGET" && columnName == "BLOB" | |
variables.put((objectName, columnName, typeCode, index), (rs.getString(i), json)) | |
} | |
} | |
} | |
variables.toMap | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment