Vaadin 8 on Grails 3
  • Introduction
  • Project setup
    • Environment setup
      • Unix based systems
      • Windows
    • Creating Project
      • Command line
      • IntelliJ IDEA
    • Plugin Configuration
      • UI class
      • URL mapping
      • Production mode
      • Async support
      • Themes
      • SASS compilation
      • Widgetset compilation
      • Servlet class
      • Spring component scan
      • UI provider
      • Open session in view
    • Clean up
    • Best Practices
  • Database
    • GORM
      • Create Domain Model
      • Transactions
      • LazyInitializationException
      • Open Session In View I.
      • Open Session In View II.
      • Table Container
    • Groovy SQL
      • Create Sql Bean
      • Execute SQLs
    • MyBatis
      • MyBatis Configuration
      • Reading Data with MyBatis
    • JdbcTemplate
      • Create JdbcTemplate Beans
      • Using JdbcTemplate
    • Clean Up When Using Alternatives
  • UI
Powered by GitBook
On this page
  • Step 1
  • Step 2

Was this helpful?

  1. Database
  2. JdbcTemplate

Create JdbcTemplate Beans

PreviousJdbcTemplateNextUsing JdbcTemplate

Last updated 5 years ago

Was this helpful?

Example code is available on .

In this article, we will show how to define beans in order to start working with .

Step 1

Add dependency to into BuildConfig.groovy.

dependencies {
    compile 'org.springframework:spring-jdbc:4.0.6.RELEASE'
}

Step 2

We can use JdbcTemplate to directly execute SQL queries, but if there will be inputs from users, we have to use ? as a parameter placeholder or rather use NamedParameterJdbcTemplate to prevent .

import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate

beans = {

    jdbcTemplate(JdbcTemplate, ref('dataSource'))

    namedJdbcTemplate(NamedParameterJdbcTemplate, ref('dataSource'))
}
github.com/vaadin-on-grails/jdbc-template
spring-jdbc
spring-jdbc
SQL injection