보뇨 다이어리

H2 database mysql 로 작동시키기 본문

컴퓨터 관련/DB 정보

H2 database mysql 로 작동시키기

보뇨 2019. 6. 30. 14:46
반응형

JPA 사용을 위해 회사에서는 테스트 디비가 있지만 그것을 사용하기 좀 그래서 집컴퓨터로 테스트하고싶어짐
그래서 h2 라는 초초초가벼운 디비를 mysql 환경에 맞게 사용하고싶어서 mysql 로 선택하고 실행했더니 com.mysql.jdbc.driver 를 뱉.....
h2 자체가 자바로 만들어진거라 jar 파일을 그쪽으로 넣으면 되나? 싶어서 이것저것 시도했는데 안되더라군요...ㅠ
문서를 읽으니까 답이 나와있었다....역시 기승전문서
말인즉슨 디비로 로그인할때 기존 url 에 덫붙혀서 MODE=MySQL;DATABASE_TO_LOWER=TRUE 작성하면된다

//DATABASE_TO_LOWER 이거 붙히니까 h2 schema public not found sql statement 해당 에러가 남..그냥 빼고 접속하시길

MySQL Compatibility Mode
To use the MySQL mode, use the database URL jdbc:h2:~/test;MODE=MySQL;DATABASE_TO_LOWER=TRUE. Use this mode for compatibility with MariaDB too. When case-insensitive identifiers are needed append ;CASE_INSENSITIVE_IDENTIFIERS=TRUE to URL. Do not change value of DATABASE_TO_LOWER after creation of database.

When inserting data, if a column is defined to be NOT NULL and NULL is inserted, then a 0 (or empty string, or the current timestamp for timestamp columns) value is used. Usually, this operation is not allowed and an exception is thrown.
Creating indexes in the CREATE TABLE statement is allowed using INDEX(..) or KEY(..). Example: create table test(id int primary key, name varchar(255), key idx_name(name));
When converting a floating point number to an integer, the fractional digits are not truncated, but the value is rounded.
Concatenating NULL with another value results in the other value.
ON DUPLICATE KEY UPDATE is supported in INSERT statements, due to this feature VALUES has special non-standard meaning is some contexts.
INSERT IGNORE is partially supported and may be used to skip rows with duplicate keys if ON DUPLICATE KEY UPDATE is not specified.
REGEXP_REPLACE() uses \ for back-references for compatibility with MariaDB.
Datetime value functions return the same value within a command.
Text comparison in MySQL is case insensitive by default, while in H2 it is case sensitive (as in most other databases). H2 does support case insensitive text comparison, but it needs to be set separately, using SET IGNORECASE TRUE. This affects comparison using =, LIKE, REGEXP.

출처

http://www.h2database.com/html/features.html

반응형