Hazzle
20
2018-12-07 14:32:30
5
95

쿼리결과중에 날짜필드만 null로 가져옵니다.


안녕하세요..

샘플게시판을 만들고 있는데요..

쿼리시 다른 필드들의 값은 가져오는데 날짜필드는 값이 있는데도 null로 가져와서

로그를 찍어 첨부합니다.



[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@27b90bb4 - Field level information: 

com.mysql.jdbc.Field@1698a838[catalog=redate,tableName=board,originalTableName=board,columnName=id,originalColumnName=id,mysqlType=8(FIELD_TYPE_LONGLONG),flags= AUTO_INCREMENT PRIMARY_KEY, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@5d07a17f[catalog=redate,tableName=board,originalTableName=board,columnName=boardno,originalColumnName=boardno,mysqlType=1(FIELD_TYPE_TINY),flags=, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@63518219[catalog=redate,tableName=board,originalTableName=board,columnName=subject,originalColumnName=subject,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

com.mysql.jdbc.Field@cdac16c[catalog=redate,tableName=board,originalTableName=board,columnName=content,originalColumnName=content,mysqlType=253(FIELD_TYPE_VAR_STRING),flags= BLOB, charsetIndex=33, charsetName=UTF-8]

com.mysql.jdbc.Field@5fd071a7[catalog=redate,tableName=board,originalTableName=board,columnName=writer,originalColumnName=writer,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

com.mysql.jdbc.Field@3fbc3f7b[catalog=redate,tableName=board,originalTableName=board,columnName=password,originalColumnName=password,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

com.mysql.jdbc.Field@501223df[catalog=redate,tableName=board,originalTableName=board,columnName=register_datetime,originalColumnName=register_datetime,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@a195910[catalog=redate,tableName=board,originalTableName=board,columnName=update_datetime,originalColumnName=update_datetime,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@56185cbd[catalog=redate,tableName=board,originalTableName=board,columnName=block,originalColumnName=block,mysqlType=1(FIELD_TYPE_TINY),flags=, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@801e6e2[catalog=redate,tableName=board,originalTableName=board,columnName=dolike,originalColumnName=dolike,mysqlType=3(FIELD_TYPE_LONG),flags=, charsetIndex=63, charsetName=US-ASCII]

com.mysql.jdbc.Field@49cc20e6[catalog=redate,tableName=board,originalTableName=board,columnName=boardHit,originalColumnName=boardHit,mysqlType=3(FIELD_TYPE_LONG),flags=, charsetIndex=63, charsetName=US-ASCII]  org.apache.commons.dbcp2.DelegatingResultSet.getMetaData(DelegatingResultSet.java:347)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getType() returned 1003  org.apache.commons.dbcp2.DelegatingResultSet.getType(DelegatingResultSet.java:443)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.next() returned true  org.apache.commons.dbcp2.DelegatingResultSet.next(DelegatingResultSet.java:191)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(id) returned 56  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(boardno) returned 22  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(subject) returned 제목  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getClob(content) returned com.mysql.jdbc.Clob@95d2116  org.apache.commons.dbcp2.DelegatingResultSet.getClob(DelegatingResultSet.java:675)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(writer) returned 홍길동  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(password) returned 1234  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(block) returned 0  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(dolike) returned 0  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned true  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(boardHit) returned 75  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [INFO ] jdbc.resultsettable.resultSetCollected - 

|---|--------|--------|----------|-------|---------|----------------------|----------------------|------|-------|---------|

|id |boardno |subject |content   |writer |password |register_datetime     |update_datetime       |block |dolike |boardhit |

|---|--------|--------|----------|-------|---------|----------------------|----------------------|------|-------|---------|

|56 |22      |제목      |interfase |홍길동    |1234     |2018-11-30 14:48:33.0 |2018-11-30 14:48:33.0 |0     |[null] |75       |

|---|--------|--------|----------|-------|---------|----------------------|----------------------|------|-------|---------|


[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.next() returned false  org.apache.commons.dbcp2.DelegatingResultSet.next(DelegatingResultSet.java:191)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.close() returned void  org.apache.commons.dbcp2.DelegatingResultSet.close(DelegatingResultSet.java:170)

[2018-12-07 14:17:38] [http-nio-8080-exec-1] [INFO ] c.l.c.work.board.BoardController.boardList - 날짜가 null ???? : {list=[BoardVO(id=56, boardno=22, subject=제목, content=interfase, writer=홍길동, password=1234, register_datetime=null, update_datetime=null, block=0, dolike=0, boardHit=75)]}




0
0
  • 답변 5

  • kiroki
    169
    2018-12-07 16:00:10

    쿼리를 DB에서 실행하면 date가 찍히나요?

    0
  • Hazzle
    20
    2018-12-07 16:41:12

    네.. 정상적으로 출력됩니다. 첨부한 로그 이미지를 보시면 중간네모박스에서 날짜필드만이 스킵되는 현상이 있습니다. 그렇다보니 view에서 null값이 나옵니다. 날짜필드만요..

    컨트롤 리턴 후 로그내용은

    id=56, boardno=22, subject=제목, content=interfase, writer=홍길동, password=1234, register_datetime=null, update_datetime=null, block=0, dolike=0, boardHit=75

    이렇게 됩니다.

    0
  • 팡팡이와아이들
    318
    2018-12-08 21:05:23

    값을받는부분도 보여주셔야할것같아요~~


    0
  • Hazzle
    20
    2018-12-10 18:31:14 작성 2018-12-10 18:52:31 수정됨

    컨트롤 부분입니다.


    @RequestMapping("/list")
    private String boardList(Model model, HttpServletRequest request) throws Exception {

    System.out.println(mBoardService.boardListService());

    model.addAttribute("list", mBoardService.boardListService());

    // logger.info("날짜가 null ???? : " + model);

    return "works/renewal/list";
    }

    다음은 위 print문의 내용입니다.

    com.mysql.jdbc.Field@517f8aef[catalog=redate,tableName=board,originalTableName=board,columnName=id,originalColumnName=id,mysqlType=8(FIELD_TYPE_LONGLONG),flags= AUTO_INCREMENT PRIMARY_KEY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@46a34ea6[catalog=redate,tableName=board,originalTableName=board,columnName=boardno,originalColumnName=boardno,mysqlType=1(FIELD_TYPE_TINY),flags=, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@63ca538d[catalog=redate,tableName=board,originalTableName=board,columnName=subject,originalColumnName=subject,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

    com.mysql.jdbc.Field@26cb3fe5[catalog=redate,tableName=board,originalTableName=board,columnName=content,originalColumnName=content,mysqlType=253(FIELD_TYPE_VAR_STRING),flags= BLOB, charsetIndex=33, charsetName=UTF-8]

    com.mysql.jdbc.Field@b4ee121[catalog=redate,tableName=board,originalTableName=board,columnName=writer,originalColumnName=writer,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

    com.mysql.jdbc.Field@57445890[catalog=redate,tableName=board,originalTableName=board,columnName=password,originalColumnName=password,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8]

    com.mysql.jdbc.Field@66a33fce[catalog=redate,tableName=board,originalTableName=board,columnName=register_datetime,originalColumnName=register_datetime,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@19e800e8[catalog=redate,tableName=board,originalTableName=board,columnName=update_datetime,originalColumnName=update_datetime,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@6553bd1d[catalog=redate,tableName=board,originalTableName=board,columnName=block,originalColumnName=block,mysqlType=1(FIELD_TYPE_TINY),flags=, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@10a6e9ff[catalog=redate,tableName=board,originalTableName=board,columnName=dolike,originalColumnName=dolike,mysqlType=3(FIELD_TYPE_LONG),flags=, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@6f04f96a[catalog=redate,tableName=board,originalTableName=board,columnName=boardHit,originalColumnName=boardHit,mysqlType=3(FIELD_TYPE_LONG),flags=, charsetIndex=63, charsetName=US-ASCII]  org.apache.commons.dbcp2.DelegatingResultSet.getMetaData(DelegatingResultSet.java:347)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getType() returned 1003  org.apache.commons.dbcp2.DelegatingResultSet.getType(DelegatingResultSet.java:443)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.next() returned true  org.apache.commons.dbcp2.DelegatingResultSet.next(DelegatingResultSet.java:191)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(id) returned 68  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(boardno) returned 2  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(subject) returned 111  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getClob(content) returned com.mysql.jdbc.Clob@36324b22  org.apache.commons.dbcp2.DelegatingResultSet.getClob(DelegatingResultSet.java:675)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(writer) returned 111  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getString(password) returned 111  org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:267)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    이부분에서 register_datetime과 update_datetime 필드가 누락되고 있어요

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(block) returned 0  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(dolike) returned 0  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned true  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.getInt(boardHit) returned 1  org.apache.commons.dbcp2.DelegatingResultSet.getInt(DelegatingResultSet.java:283)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.wasNull() returned false  org.apache.commons.dbcp2.DelegatingResultSet.wasNull(DelegatingResultSet.java:195)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.next() returned false  org.apache.commons.dbcp2.DelegatingResultSet.next(DelegatingResultSet.java:191)

    [2018-12-10 18:23:17] [http-nio-8080-exec-1] [DEBUG] jdbc.resultset.methodReturned - 6. ResultSet.close() returned void  org.apache.commons.dbcp2.DelegatingResultSet.close(DelegatingResultSet.java:170)


    서비스파일

    public interface BoardService {

    List<BoardVO> boardListService() throws Exception;


    서비스Impl 파일

    @Service
    public class BoardServiceImpl implements BoardService {

    @Autowired
    private BoardRepository boardRepository;

    @Override
    public List<BoardVO> boardListService() throws Exception {
    // System.out.println("===>>>>>>" + boardRepository.boardList());
    return boardRepository.boardList();
    }

    레퍼지토리파일

    package com.lovd.repository.board;

    import com.lovd.model.common.BoardVO;
    import com.lovd.model.common.BoardFilesVO;

    import org.apache.ibatis.annotations.*;

    import java.util.HashMap;
    import java.util.List;

    @Mapper
    public interface BoardRepository {

    @Select("select * from board")
    List<BoardVO> boardList() throws Exception;


    이렇게 되어 있습니다.


    DB내용입니다.(이미지가 첨부되지 않아서)

    id, boardno, subject, content, writer, password, register_datetime, update_datetime, block, dolike, boardHit

    '68', '2', '111', '111', '111', '111', '2018-12-10 18:05:45', '2018-12-10 18:05:46', '0', NULL, '3'



    컨트롤내 log를 찍은 내용입니다.

    6. select * from board

    [BoardVO(id=68, boardno=2, subject=111, content=111, writer=111, password=111, register_datetime=null, update_datetime=null, block=0, dolike=0, boardHit=3)]


    다시한번 답변 부탁드립니다.

    0
  • kiroki
    169
    2018-12-11 14:56:48

    음 혹시 BoardVO의 필드랑 DB 컬럼(register_datetime, update_datetime) 이랑 매핑이 잘되어 있나요?

    필드 이름 및 type 이요

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