spring boot 쿼리문 문제 뭐가 잘못된건가요??

spring boot 쿼리문 문제 뭐가 잘못된건가요??

작성일 2023.08.04댓글 1건
    게시물 수정 , 삭제는 로그인 필요

상황을 얘기하자면

희망도서 리스트를 

도서리스트(테이블)에 고스란히 추가하는

그런 작업인데요

사진을 input 안했을떄

희망도서 리스트 에있는 사진을 그대로 넣는다

이걸 구현하려했는데 자꾸 에러가 뜨네요 

에러메시지는 이렇고요

SQL: INSERT INTO `book` ( `library` , `title` , `imagePath` , `author` , `publisher` , `price` , `isbn` , `pubyear` , `appendix` , `createdAt` , `updatedAt` ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , now() , now() )

### Cause: java.sql.SQLException: Column count doesn't match value count at row 1

; bad SQL grammar []; nested exception is java.sql.SQLException: Column count doesn't match value count at row 1] with root cause


java.sql.SQLException: Column count doesn't match value count at row 1

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130) ~[mysql-connector-j-8.0.33.jar:8.0.33]

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.33.jar:8.0.33]

at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) ~[mysql-connector-j-8.0.33.jar:8.0.33]

at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:354) ~[mysql-connector-j-8.0.33.jar:8.0.33]

at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-4.0.3.jar:na]

at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:na]

at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.13.jar:3.5.13]

at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) ~[mybatis-3.5.13.jar:3.5.13]

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]

at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybatis-spring-2.1.1.jar:2.1.1]

at jdk.proxy2/jdk.proxy2.$Proxy63.insert(Unknown Source) ~[na:na]

at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) ~[mybatis-spring-2.1.1.jar:2.1.1]

at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) ~[mybatis-3.5.13.jar



INSERT INTO

`book`

(

`library`

, `title`

, `imagePath`

, `author`

, `publisher`

, `price`

, `isbn`

, `pubyear`

, `appendix`

, `createdAt`

, `updatedAt`

)

VALUES

(

#{library}

, #{title}

<!-- 파일업로드 예외처리 딱히 수정할거 아니면 기존의 것 업로드 -->

<if test="imagePath !=null">

, #{imagePath}

</if>

, #{author}

, #{publisher}

, #{price}

, #{isbn}

, #{pubyear}

, #{appendix}

, now()

, now()

) 


#spring boot #spring boot version #spring boot devtools #spring boot swagger #spring boot initializr #spring boot actuator #spring boot mybatis #spring boot jpa #spring boot security #spring boot mysql 연동

profile_image 익명 작성일 -

insert into book부분에

, `imagePath`

가 있는데

아래쪽에서 밸류값 넣을때는 if로 null이 아니면 이라고 처리되어 있잖아요

위에도 똑같이 null이 아니면 처리를 해주던가

아래쪽에 if처리 하지말고 nvl로 기본값을 넣어주던가 하면 될거 같은데요

springboot 사용시 이미지가 변경되면...

... springframework.boot:spring-boot-devtools' 이렇게 했는데 왜 이미지만 반영이 느리죠?... 제대로뜨는 문제는 아주 치명적인데요. 대체 뭐가 잘못된걸까요? 해당 설정은...

wwe레슬링 저지먼트데이...

... 크게 잘못된 정보였나 보군. 오늘 로디 파이퍼와의... 팀앵글이 사다리를 오르고 - 타지리가 hand Spring... big boot을 선사하고 그 문제의 턴버클에 '꽝!' 내쉬가...

★☆저지먼트 데이☆★(내공 있음)

... big boot을 선사하고 다시 그 문제의 턴버클에 '꽝!... 크게 잘못된 정보요." 미스터 아메리카는 "내가... 타지리가 hand Spring Elbow를 날려 사다리를...

WWF 레슬링 어제한 저지먼트데이에...

... 크게 잘못된 정보였나 보군. 오늘 로디 파이퍼와의... 팀앵글이 사다리를 오르고 - 타지리가 hand Spring... big boot을 선사하고 그 문제의 턴버클에 '꽝!' 내쉬가...