我在一个使用raw sql公开了Kotlin的表中插入了一行。是否可以返回行id?
val sql: String = """INSERT INTO customer (name, city) VALUES ('Tom', 'Dublin')"""TransactionManager.current().connection.prepareStatement(sql, true).executeUpdate()
val sql: String =
"""
INSERT INTO customer (name, city) VALUES ('Tom', 'Dublin')
TransactionManager.current().connection.prepareStatement(sql, true).executeUpdate()
oknwwptz1#
conn.prepareStatement(sqlString).use { statement -> statement.executeUpdate() val insertedId = (statement as ClientPreparedStatement).lastInsertID }
conn.prepareStatement(sqlString).use { statement ->
statement.executeUpdate()
val insertedId = (statement as ClientPreparedStatement).lastInsertID
}
我使用Kotlin服务器只有6个小时,也许它不能100%正确,但我只能通过cast对象获得id(通过ide调试器发现)。
1条答案
按热度按时间oknwwptz1#
我使用Kotlin服务器只有6个小时,也许它不能100%正确,但我只能通过cast对象获得id(通过ide调试器发现)。