I use PostgreSql for my main code and H2 for testing, and get different results (test fails). My class with an Enum type field SQL schema is My DAO class In my test method: Everything works with PostgreSql, but test with H2 fails with data conversion error: I think “java.sql.Types.OTHER” that I used in PreparedStatement for Gender is converted automatically
Tag: h2
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
Java H2 Mixed mode (embedded and server) external connection
I am trying to convert my existing embedded H2 database and enable external connections to it. Currently my properties are For a local connection to my db in this mode I seem to be able to connect to “jdbc:h2:file:./db;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9090” through my intellej IDE. If this database is hosted on a external server how do i connect to it? I have
h2 database persists data but resets on application start
I have a basic test for an embedded database that I’m trying to get working for a java project. As it stands now I am able to save rows to the database with my entity repository object, and after the app finishes running, I can connect to the database with intellij and see those rows are still there. But then,
spring boot – displaying object data from controller in JSP
I have a User class, two JSP and one controller. I want to register a user, store their details in a database (H2) and display user’s name after registration. This is my home.jsp – This is my controller – This is my afterRegister.jsp – The object gets added to the database. What am I doing wrong when it comes to
Escape colon (‘:’) in custom h2 Query
So I am trying to write a custom query for h2 using its JSON_OBJECT function. JSON_OBJECT uses a format of JSON_OBJECT(key:value) so as a simple example in my Spring repository I am writing a query like @Query(value = “SELECT JSON_OBJECT(‘id’:1)”, nativeQuery = true) When executing that same query in the h2-console it operates as expected but in Spring the colon(‘:’)
How close possibility to add new data in H2?
I have a problem. After adding some data to database, I need to set read-only mode for whole DB. What is the easiest way to do that using h2 embedded DB with driver manager (jdbc)? Answer You can open the whole database in read-only mode by appending ;ACCESS_MODE_DATA=r to the JDBC URL (“jdbc:h2:” + “./” + dbName + “;ACCESS_MODE_DATA=r” in
Thymeleaf’s form dont return the object to controller class’s method
I have a SpringBoot-MVC Java application with JPA/Hibernate, using a H2 database to store data and I’m trying to read and change lines of this database through web browser. I had success with the reading, but the edit page’s form with thymeleaf does not send the object I alterated to controller class. The formulary: The method that should receive the
Hibernation error many to one. How to create it correctly?
I’m trying to create a many-to-one base, but when adding via .jsp gives an error, via H2 console everything adds ok! Please help me understand how to properly create a many-to-one relationship. It …
Jooq Java CTE wrong render
I have CTE that is been creating from DSL.values: Then i am trying use it to get needed values from DB But i have only the next error I suppose it happens because of (select * from (values(cast(? as varchar)) How to fix it? Other methods without cte work fine. Answer The problem was there: “Id” is needed to be