def jdbcReader(user: String, pwd: String, url: String, id: Int): List[mutable.Map[String, String] = {
var KeyVal = mutable.Map[String, String]()
var connection: Connection = null
try {
connection = DriverManager.getConnection(url, user, pwd)
val statement = connection.createStatement()
val resultSet = statement.executeQuery("SELECT Nam, Value FROM tablename WHERE id=?".replace("?", id.toString))
while (resultSet.next()) {
val name = resultSet.getString("Nam")
val value = resultSet.getString("Value")
// println("name , value = " + name + ", " + value)
}
} catch {
case e => e.printStackTrace()
val t = e.getMessage()
}
}
如何将元素添加到地图列表并从此方法返回?我相信你已经知道我是 Scala 的新手