TRIVIUM
256
2017-12-07 18:21:25.0
6
111

게시판 등록할때 insert 쿼리문 에러 나는것 같습니다. 도와주세요..



작성하기를 딱 누르면 밑에와 같은 에러가 쭉 뜹니다. 


12월 07, 2017 6:11:15 오후 org.apache.catalina.core.StandardWrapperValve invoke

심각: Servlet.service() for servlet [action] in context with path [/tagazine] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SEQ_TB_BOARD_IDX.NEXTVAL' in 'field list'

### The error may involve sample.insertBoard-Inline

### The error occurred while setting parameters

### SQL: INSERT INTO TB_BOARD    (     IDX,        TITLE,         CONTENTS,         HIT_CNT,         DEL_GB,         CREA_DTM,         CREA_ID    )    VALUES    (     SEQ_TB_BOARD_IDX.NEXTVAL,         ?,         ?,         0,         'N',         SYSDATE,         'Admin'    )

### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SEQ_TB_BOARD_IDX.NEXTVAL' in 'field list'

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SEQ_TB_BOARD_IDX.NEXTVAL' in 'field list'] with root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SEQ_TB_BOARD_IDX.NEXTVAL' in 'field list'

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)

at com.mysql.jdbc.Util.getInstance(Util.java:383)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)

at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)

at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)

at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)

at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)

at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)

at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)

at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)

at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)

at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)

at com.sun.proxy.$Proxy4.insert(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236)

at first.common.dao.AbstractDAO.insert(AbstractDAO.java:24)

at first.sample.dao.SampleDAO.insertBoard(SampleDAO.java:19)

at first.sample.service.SampleServiceImpl.insertBoard(SampleServiceImpl.java:27)

at first.sample.controller.SampleController.insertBoard(SampleController.java:44)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)


Sample_SQL.xml 파일안에 있는 쿼리문이고요


MySQL 컬럼들입니다. 시퀀스 이름은 TB_BOARD 이고 테이블명은 BOARD입니다.


흔한개발자의 개발노트 라는 사이트를 보고 따라하는중인데..

한참을고민하다 모르겠어서 질문 올려봅니다.

제가 초보라 상세한 답변 부탁드릴게요..


0
0
  • 답변 6

  • CSS어려운것
    216
    2017-12-07 18:38:29.0 작성 2017-12-07 18:40:33.0 수정됨


    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SEQ_TB_BOARD_IDX.NEXTVAL' in 'field list'


    컬럼을 찾을수 없다는 오류가 발생했네요

    0
  • TRIVIUM
    256
    2017-12-07 18:54:01.0

    mysql 에서 

    create sequence seq_tb_board_idx

    start with 1

    increment by 1

    nomaxvalue

    nocache;


    만들려고 하는데 

    계속 create 부분에서 Syntax error : unexpected 'create' (create) 라고 에러 뜨네요

    밑에 창에는 Error Code:1064. You have an error in your SQL syntax: check the manual that~~~~

    뜨는데 왜죠....  


    0
  • 재원짱
    38
    2017-12-07 18:57:26.0

    SEQ_TB_BOARD_IDX.NEXTVAL 오라클에서 사용하는 시퀀스 입니다.

    테이블의 IDX컬럼에 ai를 체크하였으므로 자동으로 증가한 값이 들어가므로 

    쿼리에서 IDX를 빼주세요. 아래처럼요.


    INSERT INTO TB_BOARD    (         TITLE,         CONTENTS,         HIT_CNT,         DEL_GB,         CREA_DTM,         CREA_ID    )    VALUES    (            ?,         ?,         0,         'N',         SYSDATE,         'Admin'    )

    0
  • ComPuTa
    193
    2017-12-07 18:59:56.0

    MySql 은 오라클과 같은 sequence를 지원하지 않습니다. 

    PrimaryKey 설정된 필드 ( int, bint .. ) 등에 auto_increment 를 지정하여

    자동으로 id 값을 증가 시키도록 하셔야 합니다. 



    0
  • 스타
    2k
    2017-12-07 19:27:27.0

    mysql이 언제부터 시퀀스를 지원했나 싶었음.

    0
  • ktsedd
    4k
    2017-12-08 09:41:56.0

    저도 그거보고 플젝만들었는데 디비를 오라클로 써서 

    전 mysql로 바꿨는데 그것도 도움되더군요


    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.