problem about h2-Collection of common programming errors
Thomas Mueller
h2
I’m using H2 1.3.173.I have the following table:CREATE TABLE Flights (FlightId INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY HASH,AircraftId INTEGER NOT NULL,DepartureDate TIMESTAMP NOT NULL,DepartureAirport VARCHAR(3) NOT NULL,ArrivalDate TIMESTAMP NOT NULL,ArrivalAirport VARCHAR(3) NOT NULL, ); CREATE HASH INDEX idxFlightAircraftId ON Flights (AircraftId);I’m looking for the first departure airport of each aircraft with the following query:SELECT * FROM Flights A INNER JOIN (SELECT Airc
Synesso
java database h2
I’ve got a H2 database with URL “jdbc:h2:test”. I create a table using CREATE TABLE PERSON (ID INT PRIMARY KEY, FIRSTNAME VARCHAR(64), LASTNAME VARCHAR(64));. I then select everything from this (empty) table using SELECT * FROM PERSON. So far, so good.However, if I change the URL to “jdbc:h2:mem:test”, the only difference being the database is now in memory only, this gives me an org.h2.jdbc.JdbcSQLException: Table “PERSON” not found; SQL statement: SELECT * FROM PERSON [42102-154]. I’m probably
shprotova
java database testing maven-2 h2
Testing java application using H2 database 1.3.169I’m testing my app in two different ways. In-memory database is created in a separate process from the application. I start H2 console and create database from scripts. All tests pass. In-memory database is created in the same process with the application when application start. All tests pass in Intellij IDEA 11.3. Using Maven 2 for testing some tests fail(create, update, delete for the one entity, expected dataset does not match with result). I
Zack Macomber
h2
I have a file that I would like to read in H2 that uses FIELD(ASCII code 31) & RECORD(ASCII code 30) as the field and record separators in my file. I’ve tried this but it’s not working…SELECT * FROM CSVREAD(‘test.csv’, null, ‘rowSeparator=’ || CHAR(30) || ‘fieldSeparator=’ || CHAR(31));How do I need to format this to read from my file?EDIT IThis parses the fields out correctly but the rows aren’t being parsed out…not sure why:SELECT * FROM CSVREAD(‘C:\Users\zmacomber\ReceiptPrinter\data
Gili
database h2
At the time of this writing, TRANSACTION_ID() does not support in-memory databases. I can generate my own IDs using a sequence table but it’s not clear how to communicate existing IDs to triggers. The first trigger should generate a new ID. Subsequent triggers (in the same transaction) should share the existing ID.I could use thread-local variables to share the existing ID but that seems fragile. Is there a better way to do this?
Dave
hibernate jpa jpa-2.0 h2
I’m using Hibernate 4.1.0.Final, JPA 2.0, JUnit 4.8.1, and the H2 in-memory database. I have this JPA query …@Override public List<Organization> findByOrgTypesCountryAndState(final List<OrganizationType> organizationTypes,final String countryId,final String stateId) {final CriteriaBuilder builder = entityManager.getCriteriaBuilder();final CriteriaQuery<Organization> criteria = builder.createQuery(Organization.class);final Root<Organization> org = criteria.from(Organiza
Martin
java sql hibernate h2 dbunit
I’m running into an interesting issue here with a DBUnit test.We have some code that we test with DBUnit tests and a xml dataset. I have inconsistent test results with exactly the same dataset and code files among platforms, so I decided to follow the trail as I will be refactoring a part of the DB Access classes.The issue I’m running into is the following:The Dataset has 3 records that match a certain query defined in a hbm file. The query does an “order by DATE_FIELD desc”, however not all the
marius
java h2
HeadingIn one of my projects I am using h2 database with file storage.According to h2 db documentation”Empty space in the database file [is] re-used automatically. When closing the database, the database is automatically compacted for up to 200 milliseconds by default.”Empty space is created every time a row is deleted or updated. Unfortunately at runtime the database file is growing continuously. In this discussion it is suggested to backup the database, and restore it again. However I am searc
Maxime ARNSTAMM
java hibernate maven-2 configuration h2
I use maven conventions for source paths (src/main src/test) and i have my sql scripts in src/main/resources/scripts.I want to run my app with H2 memory and i’d like to use the jdbc url to initialize my db :database.url=jdbc:h2:mem:;INIT=RUNSCRIPT FROM ‘src/main/resources/scripts/create.sql’;My problem is that this relative path (src/main/… ) does not work, and that H2 won’t crash if the init=runscript command targets nothing.Does someone know what is the path i should use to make this work ?T
Tim
database corruption h2
I am extensively using H2 database for my project (lots of inserts and selects) and I have noticed that in the database directory appear binary files which have the name: database.xx.log.db.corrupt, where xx – a number.Does anybody know if there are possibility to understand what this file stands for and why it appears?
Steve McLeod
h2
My customers run my desktop product that uses H2 as an embedded database. They are in many different locales. In the crash reports that I receive from customers, the H2 exceptions report in different languages. I’d like these messages always to be in English. How can I do this?For example, I received this today in a crash report:java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.barbarysoftware.c.b.g: PreparedStatementCallback; SQL []; Division durch 0: “0” Division by zero
Oleg Kunov
scala h2 squeryl
I’m writing a simple Scala & Squeryl application. For test purposes, each time I run ‘test’ in sbt, an in-memory H2 db is created and populated with test data. After each run I can see that memory usage of java.exe (inside which sbt is running) in the Task Manager increases until after 4 or 5 runs it crashes with OutOfMemoryError. Am I missing something that explicitly releases memory used by H2 or Squeryl? By now, I use only Session.create and then Persistence.create. Here is an excerpt fro
Jim
java tomcat jdbc database-connection h2
This is related to this post. I think I am having problem with H2 meaning that it does not close properly. I suspect this since I see myDB.lock.db when I shutdown tomcat and the process does not stop. I use Tomcat’s connection pooling and the url to the database is: url=”jdbc:h2:file:/opt/myOrg/tomcat/webapps/MyApplication/db/myDatabase;SCHEMA=myschema” From the doc close H2: Usually, a database is closed when the last connection to it isclosed…. By default, a database is closed when the las
Ossama Nasser
java crash h2 embedded-database
As you all know H2 is a powerful pure Java DBMS with several features like server/client mode and embedded When working on a little software with a H2 database ,I ran into a problem : the software crashes and the connection remains open ,when restarting the software I cannot access the database again (It’s in embedded mode so it’s locked) and to bypass this problem I had to shutdown Java virtual machine manually using task manager Is there a way in case such an event happens (application crash)
Lhunar
hibernate jpa h2
public class Group{ @ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL, mappedBy=”groups”)public Set<User> getUsers() {if(users == null)return new HashSet<User>();else return users;}public void setUsers(Set<User> users) {this.users = users;} }public class User{public void setGroups(Set<Group> groups) {this.groups = groups;}@ManyToMany(cascade = CascadeType.ALL)public Set<Group> getGroups() {return groups;} }Now if I delete a User, he should automatically be
Gili
sql h2 sql-merge
I’ve declared the following table for use by audit triggers:CREATE TABLE audit_transaction_ids (id IDENTITY PRIMARY KEY, uuid VARCHAR UNIQUE NOT NULL, `time` TIMESTAMP NOT NULL);The trigger will get invoked multiple times in the same transaction. The first time the trigger is invoked, I want it to insert a new row with the current TRANSACTION_ID() and time. The subsequent times the trigger is invoked, I want it to return the existing “id” (I invoke Statement.getGeneratedKeys() to that end) witho
holle2de
java performance hibernate view h2
here the environment: We programmed an application for a customer that is based on the embedded h2 database, it was upgraded to the latest version before doing the tests. The database consists of 29 tables and 26 views. Of the 26 views only 8 are really “used” in java, mapped view hibernate into pojos. The other views are merely doing background calculation for the others, like aggregating some values and then grouping by some column. A lot of calculation is done in those views. We decided again
AppDeveloper
java h2
I’m using H2 1.3.172 on a Windows machine with the following connection string:jdbc:h2:tcp://localhost/dev/*****;LOG=0;UNDO_LOG=0;DB_CLOSE_ON_EXIT=TRUE;IGNORECASE=TRUE;OPTIMIZE_REUSE_RESULTS=0;QUERY_TIMEOUT=180000;MAX_OPERATION_MEMORY=0;MAX_MEMORY_ROWS=30000;COMPRESS_LOB=NO;LOCK_MODE=0;MULTI_THREADED=0;CACHE_SIZE=1048576;TRACE_LEVEL_FILE=2;I receive the following exception when trying to connect to an existing database:General error: “java.lang.NullPointerException”Scenario:I have a highly compl
paissad
java database csv h2
i would like to create a new embedded h2 database from a CSV file. Here is the snippet of the csv fileCountry,City,AccentCity,Region,Population,Latitude,Longitudead,aixovall,Aixovall,06,,42.4666667,1.4833333ad,andorra,Andorra,07,,42.5,1.5166667ad,andorra la vella,Andorra la Vella,07,20430,42.5,1.5166667ad,andorra-vieille,Andorra-Vieille,07,,42.5,1.5166667ad,andorre,Andorre,07,,42.5,1.5166667I don’t want to retrieve all the fields of the csv file. Actually, i want them all except the City and Reg
JVerstry
mysql script phpmyadmin h2
I have created a local H2 database which I always opened in MySQL mode to insert data. Now, I want to export it with SCRIPT, in order to import it with phpMyAdmin on a remote MySQL database on a remote server. I get the following:SET LOCK_MODE 3; ; CREATE USER IF NOT EXISTS SA SALT ‘…’ HASH ‘…’ ADMIN; CREATE CACHED TABLE PUBLIC.RAWVALUEITEM(LANGUAGE VARCHAR(2) NOT NULL SELECTIVITY 1,RAWVALUE VARCHAR(40) NOT NULL SELECTIVITY 99,STRIPPED VARCHAR(40) NOT NULL SELECTIVITY
Contex
java jdbc classloader h2
I’m having an issue with some of my code, I’ve searched and tried everything I know of, without any luck.Scenario:Application checks if JDBC driver exists, in this case, the H2 driver (org.h2.Driver). If it doesn’t exist, the application downloads the JDBC driver and adds it to a ClassLoader like so: (note: storageDataManager is a class of mine I use for SQL methods)File h2Driver = new File(directory.toString() + File.separator + “lib” + File.separator + “h2.jar”);if (h2Driver.exists()) {URL[] u
Timii
java eclipse ant junit4 h2
I try to run JUNIT test with eclipse and ANT they both are complainen that org.h2.Driver class is not found.I have h2-1.3.164.jar in my classpath and for proof about it here is classpath from system property java.class.path c:\trasferer\build;C:\Program Files (x86)\IBM\IMShared\plugins\org.junit4_4.3.1\junit.jar; c:\trasferer\lib\ojdbc6.jar; c:\trasferer\lib\sqljdbc4.jar; c:\trasferer\lib-test\h2-1.3.164.jar; c:\trasferer\lib-test\junit-4.8.2.jar; c:\trasferer\lib-test\log4j-1.2.14.jar; c:\trasf
TheKojuEffect
spring datasource h2
I have dataSource set up with MySQL for deployment but I want to set up a test environment with H2 database.My application context configuration with MySQL dataSource is@Beanpublic DataSource dataSource() {BasicDataSource dataSource = new BasicDataSource();dataSource.setDriverClassName(“com.mysql.jdbc.Driver”);dataSource.setUrl(“jdbc:mysql://localhost:3306/MyDatabase”);dataSource.setUsername(“username”);dataSource.setPassword(“password”);dataSource.setInitialSize(2);dataSource.setMaxActive(10);r
Pere Villega
hibernate playframework h2
I have a set of Play! unit tests that I have been running against an H2 database. I have added some enum columns to my model, and the tests now fail because of the sql statements used to create my model tables.The error message is:14:42:10,435 ERROR ~ Unknown data type: “ENUM”; SQL statement:Some searching shows that there are ways to emulate enums in H2 (eg: http://groups.google.com/group/h2-database/search?group=h2-database&q=enum&qt_g=Search+this+group)Setting Play to use the H2Dialec
Sello Lekgothoane
php connection-string h2 unixodbc
could you please assist me with this. I’m trying to connect to a H2 Database using PHP OBDC and I get the following error message: “SQL error: [unixODBC]Unknown authentication type, SQL state 28000 in SQLConnect” I use the following to connect: $DSN = “Driver=PostgreSQL;Server=$Srv;Port=5435;Database=$DB;”; $CID = odbc_connect($DSN,$usr,$pwd);How do i parse the Authentication type in the connection string. Thanks.
Bobby Quninne
spring h2 dbunit
Some context:I am doing a POC with spring batch to replace out data extracts and reporting framework. We read data from an Oracle db and generate CSV reports from there. Now I have this working and unit tests connecting to an oracle db. However I would prefer to remove the external dependency of Oracle db to test with.Problem:When it comes time to adding data to the db dbunit is complaining that the table ‘Account’ does not exist.Logging:I can see the sql to drop and create the tables being fire
Victor Nedioglo
java database oracle exception h2
I am using the H2 database (v1.3.170) for JUnit testing in my project. Our production environment uses Oracle DB so we have to do lot conversions of the DDLs exported from Oracle to make them working with H2. One of the issues we are facing right now is following:select * from table_country c where c.code > 0 AND ‘USA’ = c.name(+)This query works fine in Oracle, but fails in H2 with below stack trace:org.h2.jdbc.JdbcSQLException: Data conversion error converting “USA”; SQL statement: select *
Web site is in building