Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class DboDao { private DataSourceTransactionManager transactionManager; private JdbcTemplate jdbcTemplate; public DboDao() { // TODO Auto-generated constructor stub super(); // problem exists here, as transactionManager is not set yet and // you are using Setter Based injection so `NPE` // you can move this code in setter method of transactionManager, to make it work. DataSource datatSource = transactionManager.getDataSource(); jdbcTemplate = new JdbcTemplate(datatSource); }............. </code></pre> <p>Also, I see wrong things in your code. Use transaction manager at service layer. And inject dataSource in DboDao. And create jdbcTemplate like as below:</p> <pre><code>public class DboDao { private DataSource dataSource; // either use @Autowire or provide xml config private JdbcTemplate jdbcTemplate; public DboDao() { super(); } ....// getter and setter for jdbcTemplate and dataSource public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; jdbcTemplate = new JdbcTemplate(dataSource); } </code></pre> <p>Looking at your configuration file, if you want to make your app run: intialize dataSource and jdbcTemplate in setter methods, as you are using setter based injection.</p> <pre><code>public class DboDao { private DataSourceTransactionManager transactionManager; private JdbcTemplate jdbcTemplate; public DboDao() { super(); } //Spring setter injector used public void setTransactionManager(DataSourceTransactionManager transactionManager){ this.transactionManager = transactionManager; // moved code from constructor DataSource datatSource = transactionManager.getDataSource(); jdbcTemplate = new JdbcTemplate(datatSource); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload