h2

Insert & fetch java.time.LocalDate objects to/from an SQL database such as H2

前提是你 提交于 2019-12-27 12:07:19
问题 How to insert and fetch java.time types such as LocalDate via JDBC to an SQL database such as the H2 Database Engine? The old way using PreparedStatement::setDate and ResultSet::getDate works for the legacy java.sql.Date type. I want to avoid using these troublesome old date-time classes. What is the modern way for sending java.time types through a JDBC driver? 回答1: We have two routes to exchanging java.time objects through JDBC: JDBC 4.2 compliant drivers If your JDBC driver complies with

Syntax error in SQL statement “WITH” keyword throwing exception

为君一笑 提交于 2019-12-25 18:56:07
问题 I have also added another TMP2 and was not able to run the query... Could you please help me on this query? I am using Oracle 11g. WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE) SELECT TMP1.REQUEST_NO FROM TMP1; WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE), TMP2(AGENT) AS (SELECT AGENT FROM AGENT_TAB) SELECT TMP2.AGENT FROM TMP2; The exception I got is : org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE), [*

Import CSV in H2 DB of grails

淺唱寂寞╮ 提交于 2019-12-25 13:07:10
问题 This is a continuation to the question : Grails with CSV (No DB) I have three CSV files as my backend(in shared drive), which are constantly being updated by the greenplum DB (rows being appended) and I want to import these files in the H2DB (default) of grails and then use these files. The CSV files are 3mb, 30mb and 60 mb in size and the last one has 550,000 rows. These CSV files are updated hourly with new data(appending rows) The scheduling can be done by Quartz here. Quick questions : Is

Hibernate Entity Auditing and hbm2ddl.auto=validate in h2 and oracle

早过忘川 提交于 2019-12-25 04:33:33
问题 I have a problem with schema validation of revtype column of audit tables I have declared revtype column as number(3) everything is working fine when i'm using oracle database but when i'm switch to h2 i have exception revtype revtype column found decimal expected tinyint Any ideas how can it works on h2 and oracle ? 回答1: Extending h2 dialect and changing column definition for integer worked 来源: https://stackoverflow.com/questions/35925228/hibernate-entity-auditing-and-hbm2ddl-auto-validate

H2 equivalent to SET IDENTITY_INSERT

若如初见. 提交于 2019-12-25 02:44:55
问题 I'm using H2 to JUnit test a system that will run using MS SQL Server in production. As part of the latest version I need to make some DDL changes and migrate data from the old structure to the new. And that will involve copying data into a new table that has an identity column. I'm actually splitting a single table into two. Going forward the new table will have an independent (identity) primary key, but for initialization it needs to have the same value for the primary key as the original

Analyze Table Syntax Error

余生颓废 提交于 2019-12-24 23:19:51
问题 The following sql statement raises a syntax error: analyze table my_table sample_size 0; This is the raised error: Syntax error in SQL statement "ANALYZE TABLE MY_TABLE SAMPLE_SIZE[*] 0 "; expected "integer"; The official documentation gives the following: ANALYZE [TABLE tableName] [SAMPLE_SIZE rowCountInt] (...) The value 0 means all rows are read. How to workaround this problem? H2 1.4.196 回答1: The error results from a bug in the h2 database parsing code. A fix has been sent. I don't know

Querying the appropriate database schema

♀尐吖头ヾ 提交于 2019-12-24 10:18:16
问题 This is a follow-on question to my earlier question about specifying multiple schemata in java using jooq to interact with H2. My test H2 DB currently has 2 schemata, PUBLIC and INFORMATION_SCHEMA. PUBLIC is specified as the default schema by H2. When running a query that should extract information from eg INFORMATION_SCHEMA.TABLES the query fails with a "table unknown" SQL error. I am only able to execute such queries by executing a factory.use(INFORMATION_SCHEMA) . There are no build errors

H2 database org.h2.Driver ClassNotFoundException

廉价感情. 提交于 2019-12-24 10:05:55
问题 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:

Insert BLOB from a file into a sql script to embed H2 database

自闭症网瘾萝莉.ら 提交于 2019-12-24 08:12:00
问题 I'm creating a SQL script to create a new schema and insert some values to an embed H2 database for use with integration tests in a Spring Boot application. One of the values I need to insert is a BLOB field on the sql table. I've succesfully used the FILE_READ function as described here. INSERT INTO MY_TABLE(ID, NAME, LOGO) VALUES('1', 'test1', FILE_READ('C:/myproject/logo.png')); That function works well with full paths but I'm not been able to do that with relative paths. That doesn't work

COUNT with subquery fail on H2 database with “Duplicate column name”

烈酒焚心 提交于 2019-12-24 07:29:55
问题 we aware strange behavior of H2 when querying COUNT with a subquery. Prepare table: CREATE TABLE Foo ( id INT PRIMARY KEY AUTO_INCREMENT, fieldName VARCHAR(30) NOT NULL, ); Test simple query (works fine): SELECT F1.id, F2.id from Foo as F1 INNER JOIN Foo F2 on F1.id = F2.id Test same query with count: SELECT count(*) FROM ( SELECT F1.id, F2.id from Foo as F1 INNER JOIN Foo F2 on F1.id = F2.id ) q; Got following error: [42S21][42121] Duplicate column name "ID"; SQL statement: select count(*)