• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to assign HSQL Datasource to JdbcTemplate in DatabaseFacadeImpl?

Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am currently working on a Spring Boot app, and am trying to assign a HSQL DB as the datasource of a JdbcTemplate in a DatabaseFacadeImpl class.

Below is what's currently in DatabaseFacade.java

And here is what is in DatabaseFacadeImpl.java:

Can someone please tell me what needs to be done so I can hook this up?

Most of the examples I've found online are using XML files for the configuration, but I don't know how to or want to use that approach.

I did some research on jdbcTemplate, & below is my attempt:

Should this work, or am I on the wrong track?
Posts: 1945
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to have a @Configuration class. Inside that class , you can define @Bean method that return a JdbcTemplate

The reason why I am defining JdbcTemplate as a bean because you use @Autowired to autowire JdbcTemplate in the DatabaseFacadeImpl class.
If jdbcTemplate is not a bean, you cannot autowire it.

Here is an example https://www.technicalkeeda.com/spring-tutorials/spring-4-jdbctemplate-annotation-example

What are you doing? You are supposed to be reading this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic