I was using spring jdbc template to insert some data into the database and I was getting this error.
Here is my code :
JdbcTemplate insert = new JdbcTemplate(dataSource);
for(ResultType result : response.getResultSet().getResult())
{
Object[] args = new Object[] {result.getAddress(), result.getCity(), result.getState(), result.getPhone(), result.getLatitude(), result.getLongitude(),result.getRating().getAverageRating(), result.getRating().getAverageRating(), result.getRating().getTotalRatings(), result.getRating().getTotalReviews(), result.getRating().getLastReviewDate(), result.getRating().getLastReviewIntro(), result.getDistance(), result.getUrl(), result.getClickUrl(), result.getBusinessUrl(), result.getBusinessClickUrl()};
insert.update("INSERT INTO data.carwashes ( address, city, state, phone, lat, lng, rating, average_rating, total_ratings, total reviews, last_review_date, last_review_intro, distance, url, click_url, business_url, business_click_url, category_id, zipcode_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,96925724,78701)", args);
}
Quite lengthy code.. but, basically it gets the value from a object and sticks it to a array and passed that array to insert method of jdbc template.
Any help will be appreciated.
My guess is that one of the items in your arg array is of a type not recognised by
JdbcTemplate, (i.e. it’s not aString, aDate, and so on), and so it’s callingsetObject()on the statement. The driver will then try to serialize the argument into a binary, discovers it’s not serializable, and throws the exception.Make sure the arguments in the array are all what you think they should be, e.g. they shouldn’t be instances of your own classes, but should be standard Java types.