java - JdbcTemplate NullPointerException -


I am trying to save the data with the spring's JDBC template, but I get this error message. If I work in the normal way with the preparation I have prepared it.

https://i.imgur.com/OpBpTE8.png

My CarDAO class: @Repository Services service classifies CarDAO cardoso switches {Private JdbcTemplate jdbcTemplate; Public JdbcTemplate getJdbcTemplate () {back jdbcTemplate; } Public Zero Set JdbcTemplate (JdbcTemplate jdbcTemplate) {this.jdbcTemplate = jdbcTemplate; } Public Zero save cartidab (Carben carbon) {last string sql = "enter car (make, model) value (?,?)"; Object [] parameter = new object [] {carbean.getMake () + carbean.getModel ()}; // if I do system.out.print (arrays.toString (parameter)); // it will print correctly / print the model JdbcTemplate.update (SQL, parameter); // Console says that this is the top line, but how do I get the value of both parameters? // Warning: StandardWrapperValve [Spring-Sender]: servlet.service () left an exception for servlet // springdispatcher}

Spring-base.xml

  & Lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Beam xmlns = "http://www.springframework.org/schema/beans" xmlns: reference = "http://www.springframework.org/schema/context" xmlns: xsi = "http: // www. W3. org / 2001 / XMLSchema-instance "xmlns: mvc =" http://www.springframework.org/schema/mvc "xsi: schema location =" http://www.springframework.org/schema/beans http: // www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0. xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> & Lt; Reference: component-scan base-package = "bean, dao" /> & Lt; Bean square = "org.springframework.web.servlet.view.InternalResourceViewResolver" & gt; & Lt; Property Name = "Prefix" Value = "/ Web-ANF / JSP /" /> & Lt; Property name = "suffix" value = ".jsp" /> & Lt; / Bean & gt; & Lt ;! - Data Sources - & gt; & Lt; Bean id = "datasource" class = "org.apache.commons.dbcp.basicDataSource" deleted-method = "off" & gt; & Lt; Property Name = "driverClassName" value = "org.mariadb.jdbc.Driver" /> & Lt; Property name = "url" value = "jdbc: mariadb: // xxxxx" /> & Lt; Property name = "user name" value = "xxxxx" /> & Lt; Property name = "password" value = "xxxxx" /> & Lt; Property name = "initial size" value = "1" /> & Lt; Property Name = "Maxactive" value = "5" /> & Lt; / Bean & gt; & Lt; Bean id = "jdbcTemplate" class = "org.springframework.jdbc.core.JdbcTemplate" & gt; & Lt; Property Name = "Data Source" Riff = "Data Sources" / & gt; & Lt; / Bean & gt; & Lt; Mvc: annotation-operated / & gt; & Lt; / Bean & gt;   

I did not include my controller or the CarDAOService class because I think the problem is not there, they are forwarding the right parameters for the cargo class.

You comment on @Autowired your setter:

  @Autown Public Zero Set JDBC Template (JDBC Template JDBC Template) {this.jdbcTemplate = jdbcTemplate; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -