h2

Mismatch between DATETIME values in H2 and MySQL databases inserted from Java/Kotlin

时光总嘲笑我的痴心妄想 提交于 2019-12-24 07:27:20
问题 TLDR: How to always save correct UTC date time value into the field of DATETIME type of both H2 and MySQL databases with Java Hibernate? Full context: I have a table with DATETIME field in the database and I want to insert rows where: by default (when no value is given) will be stored current UTC time or if the UTC date time is given, it should be stored without additional timezone conversions. The problem that it has to run on local H2 database as well as on local mysql inside Docker and on

H2 - Multiple applications access same H2 database

夙愿已清 提交于 2019-12-24 04:52:50
问题 I am using embedded database H2 in 2 web applications say WebApp1 and WebApp2 . I run WebApp1 and execute some query to access H2 database. Mean while I run WebApp2, but it throws exception that H2 is currently been used by another process My need is, I should be able to use H2 database by WebApp1 and WebApp2 at the same time. I analysed the below link but it tells about multiple connections but not about multiple applications. http://www.h2database.com/html/features.html#multiple_connections

H2 - Multiple applications access same H2 database

≡放荡痞女 提交于 2019-12-24 04:51:06
问题 I am using embedded database H2 in 2 web applications say WebApp1 and WebApp2 . I run WebApp1 and execute some query to access H2 database. Mean while I run WebApp2, but it throws exception that H2 is currently been used by another process My need is, I should be able to use H2 database by WebApp1 and WebApp2 at the same time. I analysed the below link but it tells about multiple connections but not about multiple applications. http://www.h2database.com/html/features.html#multiple_connections

Create view on h2 database

心已入冬 提交于 2019-12-24 04:48:09
问题 I'm trying to create a view on H2SQL, but i cannot find the correct syntax. I'm using: CREATE VIEW dbo.Log AS SELECT * FROM dbo.MyTable And i receive the error: Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE VIEW DBO.LOG "; expected "COMMENT, (, AS"; What is the right syntax? 回答1: It's a bug on this version of h2 (1.4.182). When running a CREATE VIEW from a RUNSCRIPT command, it doesn't handle well the line-breaks (\n) on the file. I resolved adding a comment (

Does H2 support a collation defintion for one single column?

社会主义新天地 提交于 2019-12-24 03:54:31
问题 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? 回答1: H2 only supports one collation per database (via SET COLLATION statement). What it does support is a case-insensitive data type, VARCHAR_IGNORECASE. Internally, this data type is using String.compareToIgnoreCase. This

How can I use Grails DB Migration with Spring Security and the default DB, H2?

别说谁变了你拦得住时间么 提交于 2019-12-24 03:27:05
问题 I'm running into an exception generated by the Grails Database Migration plugin. In JIRA, it says this is a bug won't fixed. But, I want to use Spring Security with the default DB, H2 , because it's easy to use to make a simple application. How can I avoid this bug except changing DB to MYSQL or ORACLE ? UPDATE Following the solution in JIRA, I changed the name of the column which has made the error, password , to passwd in User.groovy. A part of User.groovy shown below. String username

add trigger to every table in my H2 database

此生再无相见时 提交于 2019-12-24 02:48:16
问题 im trying to add a trigger to every database table in my h2 database but im not sure how to do it. I can select all the tables in the database but how do i loop through them to apply a trigger to each of them like below? SELECT * FROM INFORMATION_SCHEMA.TABLES and loop through each one and apply a trigger to each CREATE TRIGGER MYTRIGGER AFTER INSERT ON TableName FOR EACH ROW CALL\"test.h2Trigger\" 回答1: You can try create a stored procedure,in which you open a cursor to get each table name,

H2 database User defined java function Class not found

本小妞迷上赌 提交于 2019-12-24 01:53:26
问题 When I create an ALIAS for registering the java function in the H2 database, it gives error of class not found. I am running the h2 database on a tcp connection. sample, public class TimeFrame { public static void main(String... args) throws Exception { Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection("jdbc:h2:tcp://MYIP:9092/~/test", "sa", ""); Statement stat = conn.createStatement(); //Setup Table stat.execute("DROP TABLE IF EXISTS timeframe"); stat.execute(

Embedded h2 database: getting connection but table not found

六眼飞鱼酱① 提交于 2019-12-24 01:46:44
问题 I am using h2 embedded db. When I start my application the db gets initialized and I am able to get connection object. However when application tries to insert data in the table it throws the sql exception 'table XXXX not found'. I am able to view the tables from H2 consoles. And same query runs perfectly on the console. Going through some of the answers of the other question on this topic, I've understood such behavior occurs when the database is empty. But from the H2 console I am able to

Inserting a long text in H2 Database from an SQL script

若如初见. 提交于 2019-12-23 19:31:15
问题 I'm trying to run a sql script using H2's runscript. One of the table contains a longtext type which stores an xml document (from an SAP database) So the Insert statement contains the long text of the XML (about 200 lines of XML), which is rather ugly but still expected to work. H2 crashes with an ArrayOutOfBoundException during SQL parsing. Is there alimit on the length it will accept for a insert statement ? In the nsert I'm delimiting the value(xml) using ticks (as used in mysql) ...