Answer the question
In order to leave comments, you need to log in
How correctly to make query in my case?
** How to pass the Enum type to the database ? Using java.sql.Types ?
The whole problem is in the last type COUPON_TYPE .
if(findInDatabase(mappedObject) == NOT_EXIST){
String query = "INSERT INTO coupons (COUPON_ID,COUPON_AMOUNT,EXPIRATION_DATE,COUPON_IMAGE,COUPON_MESSAGE,COUPON_PRICE,RELEASE_DATE,COUPON_TITLE,COUPON_TYPE) values(?,?,?,?,?,?,?,?,?)";
List<SqlParameter> types = getParametersForQuery(new Object[]{Types.BIGINT,Types.BIGINT,Types.DATE,Types.VARCHAR,Types.VARCHAR,Types.DOUBLE,Types.DATE,Types.VARCHAR,Types.JAVA_OBJECT},9);
csQuery(query,types).updateDatabase(new Object[]{coupon.getId(), coupon.getAmount(), coupon.getEndDate(),coupon.getImage(), coupon.getMessage(), coupon.getPrice(), coupon.getStartDate(), coupon.getTitle(), coupon.getType()});
public enum CouponType {
RESTAURANTS,ELECTRICITY,FOOD,HEALTH,SPORTS,CAMPING,TRAVELING
}
Exception in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: SQL [INSERT INTO coupons (COUPON_ID,COUPON_AMOUNT,EXPIRATION_DATE,COUPON_IMAGE,COUPON_MESSAGE,COUPON_PRICE,RELEASE_DATE,COUPON_TITLE,COUPON_TYPE) values(?,?,?,?,?, ?,?,?,?)]: given 9 parameters but expected 8
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question