Skip to content

Tag: h2

Use H2 as test DB in JUnit5

I’m developing an app in Spring Boot. I use a PostreSQL DB for production, and I want my JUnit 5 tests to run on a H2 memory DB. Problem is, after some configuration, the tests still don’t seem to run on the in-memory db: I can access entities from the prod db (a saved entity doesn’t persist in the prod

How to display hashed MD5 value as text displayed in H2?

The H2 HASH function returns bytes, and SELECT HASH(‘MD5’, ‘test’) AS new_id FROM my_table; displays a text value: 098f6bcd4621d373cade4e832627b4f6 How to retrieve that same text value in Java? Using ResultSet.getBytes(“new_id”) gives the object’s address, something like [B@48f278eb. Feeding that through new String(ResultSet.getBytes(“new_id”), StandardCharsets.UTF_8) gives gobbledygook: �Oh�؆nr�Mz��. Answer The reason you see [B@48f278eb is because the resulting MD5 hash is in

org.h2.jdbc.JdbcSQLSyntaxErrorException h2 database java

Exception in thread “main” org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “INSERT INTO SMTP_DATA(SMTP_SERVER, SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM, SMTP_TO) VALUES (DEMO.STMP.COM, DEMOUSERNAME, DEMOPASSWORD, FROMDEMO@[*]MAIL.COM, TODEMO@MAIL.COM);”; expected “(, ., [, ::, AT, FORMAT, *, /, %, +, -, ||, ~, !~, NOT, LIKE, ILIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ,, )”; SQL statement: I am kind new to h2 and sql statments

After trying to test connection to h2 database or connect whitelabel error occurs

After running Spring boot project and going to localhost:8080/h2-console and after trying to connect to my database I get whitelabel error when i click any button on h2-console screen. I am using in memory database. I am trying to connect to database with classic username:sa and password:(blank) Even after clicking Save i get whitelabel error application properties: pom xml: configure