Last active
October 13, 2016 15:28
-
-
Save elifarley/a9e5002bbeee3f8571803ae582913b4b to your computer and use it in GitHub Desktop.
JdbcTemplate examples in Kotlin
This file contains hidden or 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
. |
This file contains hidden or 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
package com.orgecc.myproj.repository | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.jdbc.core.JdbcTemplate | |
import org.springframework.stereotype.Repository | |
import javax.sql.DataSource | |
@Repository | |
open class JdbcTemplateRepository @Autowired constructor(dataSource: DataSource) { | |
private val jdbcTemplate: JdbcTemplate | |
init { | |
this.jdbcTemplate = JdbcTemplate(dataSource) | |
} | |
private fun delete(from: String) = jdbcTemplate.update("DELETE FROM $from") | |
open fun deleteMyTable() = delete("MY_TABLE") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment