Skip to content

Tag: h2

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 databa…

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 tha…

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:”…

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…