[서버][스프링] Caused by: org.h2.jdbc.JdbcSQLException: Unknown data type: "USERID"; SQL statement:

프로그래밍/서버2021. 3. 26. 13:30

문제 현상

IntelliJ에서 스프링 앱을 실행 시키면 아래의 에러가 발생함

Caused by: org.h2.jdbc.JdbcSQLException: Unknown data type: "USERID"; SQL statement:

 

원인

DROP TABLE IF EXISTS kakaoUserMoneyBookRoomInfo;

CREATE TABLE IF NOT EXISTS `kakaoUserMoneyBookRoomInfo` (
  `roomNo` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'roomId는 있어서.. no로.',
  `roomOrder` smallint(6) NOT NULL DEFAULT '0',
  `userId` varchar(50) NOT NULL,
  `roomId` varchar(20) NOT NULL,
  `roomNickName` varchar(40) NOT NULL COMMENT '가계부방 별명',
  `roomAuth` tinyint(1) NOT NULL DEFAULT '0' COMMENT '방 권한',
  `roomBaseDay` tinyint(3) NOT NULL DEFAULT '1' COMMENT '조회 기준 날짜(일)',
  `roomDecimalPoint` tinyint(1) NOT NULL DEFAULT '0' COMMENT '소수점 표시 자리',
  `autoSmsStatus` tinyint(2) NOT NULL,
  `notification` tinyint(1) NOT NULL,
  `img_count` int(10) unsigned NOT NULL,
  `item_count` int(10) unsigned NOT NULL,
  `roomPriceSumStatus` tinyint(1) NOT NULL COMMENT '방 잔액 설정',
  `thumbStatus` tinyint(1) NOT NULL,
  `category` varchar(10) NOT NULL COMMENT 'default category',
  `autoNotificationStatus` tinyint(2) NOT NULL COMMENT '알림자동인식',
  PRIMARY KEY (`roomNo`),
  KEY `userId` (`userId`),
  KEY `roomOrder` (`roomOrder`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

h2에서 불러오는 schemal.sql은 위의 코드임

위 코드로 MySQL 테이블은 정상 생성되나 h2에선 인덱스 설정하는 코드를 제대로 인식하지 못하는 것으로 보임

(h2의 MySQL 호환성 문제인듯)

 

해결 방법

일단 문제가 되는 index 설정부분의 코드를 삭제하면 됩니다.

  KEY `userId` (`userId`),
  KEY `roomOrder` (`roomOrder`)

 

 

 

참고

stackoverflow.com/questions/6661170/meaning-of-a-key-in-create-table-statment-in-mysql

 

meaning of a KEY in CREATE TABLE statment in mysql

I am working with mysql . I have checked the CREATE table statement , and I saw there a KEY word | pickupspc | CREATE TABLE `pickupspc` ( `McId` int(11) NOT NULL, `Slot` int(11) NOT NULL, `

stackoverflow.com

www.h2database.com/html/commands.html

 

Commands

  Commands Index Commands (Data Manipulation) SELECT INSERT UPDATE DELETE BACKUP CALL EXECUTE IMMEDIATE EXPLAIN MERGE INTO MERGE USING RUNSCRIPT SCRIPT SHOW Explicit table Table value WITH Commands (Data Definition) Commands (Other) Details Click on the h

www.h2database.com

stackoverflow.com/a/17054632/7225691

 

H2 database Unsuccessful schema statement when add index and foreign key constraint

H2 does not appear to support the index/FK syntax generated by hibernate for the MySQL5 dialects when using ;MODE=MYSQL and hibernate with a dialect of org.hibernate.dialect.MySQL5Dialect. My goal...

stackoverflow.com

 

작성자

Posted by 드리머즈

관련 글

댓글 영역