Questions tagged [h2]

0

votes
0

answer
3

Views

EclipseLink does not see created tables in H2 DB

For test run of the application I am using H2 database 1.4.197. The app is deployed on TomEE 7.1.0 which uses EclipseLink 2.6.4. I see in logs that during the startup EclipseLink creates tables, sequences etc. Even initialize sequence with value 0: [EL Fine]: 2019-02-13 20:25:37.442--ServerSession(1...
Adam
1

votes
0

answer
5

Views

Spring Boot: Setting Hibernate naming strategy with @DataJpaTest and Flyway

I have noticed an odd behavior when trying to use the @DataJpaTest annotation in a Spring Boot test that also uses Flyway. Given the following entity class: @Entity public class MyEntity { @Id private String columnA; private String columnB; public String getColumnA() { return columnA; } public void...
Patrick
-1

votes
0

answer
14

Views

How to access H2 database from any post

I have create H2 database for a project. Actually i have a local database and it usable only on my post. public Connection getConnection(){ try { //Class.forName("com.mysql.jdbc.Driver"); Class.forName("org.h2.Driver"); conn = DriverManager.getConnection("jdbc:h2:~/DofusCraft", "root", "...
Totostore
1

votes
0

answer
9

Views

H2 database gets activated by default, although I have enabled oracle from Spring boot property files

We use hierarchically organised Spring boot property files in our application. For example, Our application.properties will just contain a single line. spring.profiles.include = logging, kafka, oracle, misc Where all the values separated by comma here are other property files (namely application-log...
Aryan Venkat
0

votes
0

answer
4

Views

H2 PL/SQL function call always fails due to “No data is available [2000-197]”

I got an H2 database configured for testing, main DB is ORacle, but can't make a call to a dummy H2 PL/SQL function work. In my src/test/resources/schema.sql file: create schema if not exists PKG_MY_PACKAGE; create alias if not exists PKG_MY_PACKAGE.MY_FUNCTION for "com.utils.PkgMyPackage.myFunction...
pablo
1

votes
2

answer
664

Views

How to reset H2 Database to the original state after Jhipster jdl-generation?

I have this project that I ran in Jhipster with the generator yo jhipster:import-jdl. When it ends, everything is clean and ready to start. This is the state I would like to easily return to, in the H2 persistent disk copy, when I do tests, changes and so on, to start all over again. I guess that us...
Mike
1

votes
2

answer
1.7k

Views

Does SQLAlchemy support H2DB?

Does SQLAlchemy support H2 db? I'm using pyramid and would like to connect to H2 db database. If using postgres dialect, I'm getting error like the following: File "/Users/homecamera/gotocamera/hcadmin/env/lib/python2.7/site-packages/SQLAlchemy-0.7.3-py2.7-macosx-10.4-x86_64.egg/sqlalchemy/dialects/...
carbotex
1

votes
1

answer
1.5k

Views

H2 database grant thinks sequence is a table

I'm running a script on H2 that does the following: create role admin_role; create user app_user password 'password' ; grant admin_role to app_user; create sequence from_event_seq; grant select on from_event_seq to admin_role; Frustratingly this is not working and I get the following error: [Error C...
DaveRlz
1

votes
1

answer
1.1k

Views

How can i increase H2 Select Query Performance?

i have an application written in Play Framework 1.2.5 and i am using H2 File as database. The application has a "Sales" Table that gets about 1000 rows per day. i have about 5 years of data in it (usually 2-3 years data will be available) so basically i have a table with 1.5Mil+ data in my test mac...
dreampowder
1

votes
1

answer
879

Views

Scala Slick 0.11.2 count with H2

I tried to build a count query with an sample DB from https://github.com/slick/slick-examples/blob/master/src/main/scala/scala/slick/examples/lifted/FirstExample.scala : // Definition of the SUPPLIERS table object Suppliers extends Table[(Int, String, String, String, String, String)]("SUPPLIERS")...
Brice
1

votes
2

answer
698

Views

Do I need to run “analyze” in a H2 database when using Hibernate

On a previous project using Mysql database I had to use ANALYZE tablename when a lot of data was added to the table so that the database created sensible query plans for SQL. Now I'm using H2 with Hibernate, do I need to worry about this anymore or does Hibernate look after this for me?
Paul Taylor
1

votes
1

answer
1.7k

Views

H2: SELECT DISTINCT slow despite low selectivity

I am using H2 and have a simple query that looks like this: SELECT DISTINCT col FROM PUBLIC.TABLE; H2 uses a full table scan, even though the selectivity is low, and there is a non-unique index on col. I checked this and ran: SELECT SELECTIVITY(CLUSTERNODE ) FROM PUBLIC.TRANSFORMATION; Which return...
Michael Böckling
1

votes
1

answer
745

Views

Gradle h2 ormlite: no such method setDriver()

I'm trying to set up a very simple ormlite stack with embedded h2. The app blows up due to a NoSuchMethodError in ormlite: Caused by: java.lang.NoSuchMethodError: com.j256.ormlite.db.DatabaseType.setDriver(Ljava/sql/Driver;)V at com.j256.ormlite.jdbc.JdbcConnectionSource.initialize(JdbcConnectionSou...
Chris
1

votes
1

answer
1.7k

Views

Why do I get an H2 error when deploying my Grails WAR to Tomcat

I'm trying to deploy my Grails 2.2.4 application to Tomcat 6.5. The application has two environments configured in DataSource.groovy. Whether I build my application using 'mvn clean package' or thru the 'grails war' I get an error about a particular table not existing. When I launch the application...
TheAmpersand
1

votes
1

answer
1.3k

Views

Cannot see content of h2 database when using it “in-memory”

i am currently developing a spring mvc app with my domain models mapped to a h2 database by hibernate (4). My current problem is, that when i start the h2 webserver as bean (see context below) i cannot see the database when it´s created "in-memory" via the jdbcUrl of the datasource. Setting the jdb...
limepix
1

votes
1

answer
6.2k

Views

playframework org.hibernate.PersistentObjectException: detached entity passed to persist: models

I am trying to set up application with playframework 2.2 with JPA and H2 database. I went with this: http://www.playframework.com/documentation/2.2.x/JavaJPA and computer-database-jpa sample project I AM GETTING AN ERROR: org.hibernate.PersistentObjectException: detached entity passed to persist: mo...
masterdany88
1

votes
2

answer
2.1k

Views

How to draw database Table items onto a TableView using hibernate

Thank you all with the help so far in my project. I've been looking at this for most of today, but have been unsuccessful in getting any helpful material. My project is in Java/ JavaFx, Hibernate and H2. So far I can persist items into the database but I cant figure out how to go about pulling the d...
ILikeProgramming
1

votes
1

answer
921

Views

Data type of a foreign key referencing Identity?

Basically, I'm confused about H2 use of Identity as keyword and as data type. What's the proper data type of B.ref as a foreign key reference to A.id? create table A(id IDENTITY) create table B(id IDENTITY, ref ???) alter table B add constraint BRefOK foreign key (ref) references public.A; The h2...
Stefan K.
1

votes
2

answer
1.8k

Views

Does H2 support a collation defintion for one single column?

I want to make a single H2 column in a H2 database to have a other collation (case insensitive) then the other columns (that are case sensitive). In MySQL I would do this: ALTER TABLE users MODIFY login VARCHAR(255) COLLATE utf8_general_ci Is there a similar feature in H2?
Ralph
1

votes
1

answer
983

Views

How to properly remove H2 from Grails

I am trying to minimalize my Grails (2.4.2) app and cull out a lot of stuff that create-app generates that I'm just not going to use. One of these things is H2. I'm just not going to use it, and besides, if I needed an embedded DB, I'd prefer to use HSQLDB. So I made the following changes to my Buil...
unfettered
1

votes
1

answer
425

Views

Universal query to check whether a table exist in all RDBMS

I have searched a lot but i could not find a query which will apply to any RDBMS to check whether a table exits. Some are ok with mysql and h2 but its not compatible with oracle. Any one has a solution for this. This works for oracle but not h2 or mysql select count(*) as tblCount from user_tables w...
dnWick
1

votes
2

answer
3.2k

Views

H2 Parsedatetime yyyyMMddhhmmss

I need to parse a date like the following 20140101120000 which is yyyyMMddhhmmss to the H2 timestamp format of yyyy-MM-dd hh:mm:ss and I can't seem to figure out how to make it work. Here is what I am trying. parseDateTime('20140101000000','yyyy-MM-dd HH:mm:ss') I am getting this error Error parsing...
Shane A. Darr
1

votes
2

answer
2.4k

Views

How large can an H2 database be?

How large can an H2 database be? I have been using an H2 database with a web application I wrote in Clojure for about half a year, and the database is getting quite large: The current size of the .h2.db file is 143GB with one table containing over 330000 images. The application is fairly stable with...
meriken2ch
1

votes
1

answer
775

Views

hibernate append “0_” to table name

I have a J2EE 7 web app running on wildfly 8.2. Database is H2. Here's my entity class @MappedSuperclass public class AbstractEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; //Getters/Setters are here } @Entity public class Patient extends Abstr...
Andy
1

votes
1

answer
1k

Views

Update statement to set a column based the maximum row of another table

I have a Family table: SELECT * FROM Family; id | Surname | Oldest | Oldest_Age ---+----------+--------+------- 1 | Byre | NULL | NULL 2 | Summers | NULL | NULL 3 | White | NULL | NULL 4 | Anders | NULL | NULL The Family.Oldest column is not yet populated. There is another tab...
MattLBeck
1

votes
1

answer
2.1k

Views

Multiple independent H2 databases within one JVM

Is it possible to start up and shut down multiple H2 databases within a JVM? My goal is to support multi-tenancy by giving each user/account their own database. Each account has very little data. Data between the accounts is never accessed together, compared, or grouped; each account is entirely se...
Basil Bourque
1

votes
3

answer
1.8k

Views

Liquibase SQL error — adds column which is not null to table with existing data

I am trying to use Liquibase to transform one database into another. I have two databases and would like to run a SQL script on one to make it the same as the other one. I am using Liquibase version 3.4.1 and two H2 databases. In order to generate the SQL script I first generate the diff xml usin...
Maciek Nicewicz
1

votes
2

answer
106

Views

Java Spring Queries

i want to make a query buy i don't have acess to the h2 database schema so i dont know how are the join attributes named. I basically want to query the avaiable rooms in a hotel in a certain date interval. For that i need to make a query like this: Select Room From Room Inner Join Booking On Room.I...
MMrj
1

votes
1

answer
2.4k

Views

How do I run a Liquibase changeset on one type of db but then have LIquibase ignore it for another type?

I”m using Gradle 2.7, MySQL 5.5.46, and the Gradle Liquibase plugin (v 1.1.1). I’m running my LIquibase script on both my H2 (v. 1.4.190) in-memory database and my MySql database. How do I configure a changeset so that Liquibase will run it on the MySQL database but ignore it for the in-memory...
Dave
1

votes
1

answer
3.3k

Views

H2database connection string

For a project im working on atm, Im trying to use h2 database as an alternative to test my DAO classes. For the normal code Im using MySQL and everything is working fine there. Now I have no problem connecting to the H2 databaes, but since im using multiple classes I made 1 class for the database pr...
jemoeee
0

votes
0

answer
8

Views

Tests in Spring Boot with database H2

I am trying to run tests on a Spring Boot api with H2 database in the test, however, when trying to run the tests the system is using the application.properties in the main resource instead of the test. I tried naming the file as application-test.properties and use the annotation @ActiveProfiles("te...
user2831852
1

votes
0

answer
3

Views

doing a jdbc query on a h2 view with array_agg returns a clob type not an array type?

I have a h2 database and am trying to create a view with a column that uses array_agg on some text columns: create view full as select av.*, at.tag from anno_v av left join (select id, array_agg(tags) as tag from anno_t group by id) at on at.id = av.id I'm using clojure's java.jdbc 0.7.0 library...
atm
5

votes
1

answer
1.7k

Views

h2 VIEW has problems with correct SELECT statement

I am working on an accounting system, backed by an h2 database. I have a number of views to pull together data from the ACCOUNTS, TRANSACTIONS and TEMPLATE_TRANSACTIONS tables. Problem, in a nutshell Although I have a SELECT statement which produces exactly the data I need to see in my VIEW_TEMPLAT...
skiaddict1
1

votes
1

answer
1.8k

Views

Error executing sql script with hibernate.hbm2ddl.import_files?

I use h2 db and hibernate 4. I want to autogenerate db schema from entities and fill in db from import.sql file . Here is relevant hibernate.cfg.xml: create-drop /import.sql So when database tables are generated import.sql is called. Here is the first sql statement: insert into Borrower values (1,"G...
2

votes
3

answer
9.3k

Views

h2 & linux. how to start the database?

sorry im rather new to linux ubuntu. i have an application that i made that runs with tomcat and connects to an h2 database. it all works fine on my windows laptop. im now moving it onto my linux computer to run all the time. but im having trouble with starting the database. i have downloaded h2 fro...
David
1

votes
1

answer
2.7k

Views

H2 equivalent of Postgres `SERIAL` or `BIGSERIAL` column?

In Postgres, defining a column with SERIAL/BIGSERIAL has a triple effect as discussed here: Define a int/bigint column. Create a sequence object to generate auto-incrementing numbers. Set the default of the column to call nextval() on the sequence. Is there a similar shortcut command in H2 to get th...
Basil Bourque
2

votes
1

answer
5.6k

Views

Writting complex stored procedures in H2 database

I have an oracle stored procedure in which first of all I am opening a cursor with complex select query using "cases" and later iterating the cursor and then inserting or updating the records based on some condition. I want this to be written in H2 database. Any help would be appreciated.
Vikash
2

votes
2

answer
1.3k

Views

Webservice calls within the same JDBC transaction are causing DB lock timeouts

I'm using the H2 database embedded within a Spring-MVC app. I have declare Transactions at my service level. In particular I have a case where we do the folllowing: Start a transaction Make a webservices call Make the subsequent database calls Upon rollback (an exception), the webservices call is ma...
David Parks
2

votes
1

answer
483

Views

JPA Criteria select with two subqueries / joins

I'm fighting this whole day and I can't figure it out. I'm JPA beginner, so for now Criteria API is a nightmare for me. The problem: I have 3 entities: Policy, Customer, Insurer. Policy has references to a Customer and an Insurer (eager fetch here). Customer has list of policies, so do Insurer (lazy...
newbie_david
2

votes
1

answer
982

Views

How to solve table locking on H2 using Spring Boot and JPA?

I seem to have struck an issue and have no real clue on how to solve. My current app is based on Spring Boot with JPA and the following code gets a lock when run for the second execution. @RequestMapping(value="/", method = RequestMethod.GET) public String index() { repository.save(new RawData("test...
Marco

View additional questions