h2

Howto insert geometry in h2 using sql

非 Y 不嫁゛ 提交于 2019-12-11 01:00:01
问题 Since a couple of versions, h2 does have support for spatial geometries. It's not a problem to select and insert geometries in java. But how can insert them in pure sql? Documentation shows it uses WKT. But when I try to insert in WKT I got an error. That's an example insert: insert into feature (id, name, description, geom) values (1, 'example name', 'example description', 'SRID=4326;POINT(7 52)'); Thanks for any hints! 回答1: As far as I see, the suffix SRID=4326 is not WKT (Well-Known Text),

How see the data of my data base H2, why localhost:8080/h2_console not work?

[亡魂溺海] 提交于 2019-12-11 00:56:52
问题 I want to see the data in my database h2. I do not know what I'm wrong about I have this configuration in file .properties spring.h2.console.enabled=true spring.h2.console.path=/h2_console spring.datasource.url=jdbc:h2:file:~/test spring.datasource.username=sa spring.datasource.password= spring.datasource.driverClassName=org.h2.Driver spring.jpa.show-sql=true spring.jpa.generate-ddl=true #spring.jpa.hibernate.ddl-auto=create spring.jpa.hibernate.ddl-auto = update #spring.jpa.hibernate.hbm2ddl

How to configure FS database in playframework 2.0?

情到浓时终转凉″ 提交于 2019-12-11 00:50:27
问题 is it possible at all? Seems easy to be done in the first version of the framework. 回答1: Instead of using # Default database configuration db.default.driver=org.h2.Driver db.default.url="jdbc:h2:mem:play" you should be able to just use # FS database configuration db.default.driver=org.h2.Driver db.default.url="jdbc:h2:playdb" This will create the file in the current working directory. See the H2 CheatSheet for more information 来源: https://stackoverflow.com/questions/10150287/how-to-configure

SQL query within hibernate extremely slow while very fast using SQL cient

人盡茶涼 提交于 2019-12-11 00:47:45
问题 I know there have been quite a few similar questions but I cant find an answer to this one: I'm not very familiar with hibernate but I'm working on an app which contains an extremely slow hibernate query. This query is generated from a very simple query in the code: Criteria crit = session.createCriteria(clazz); // clazz is the class of the Entities to load return crit.list(); There are probably a lot of possibility which could make this query extremey slow (hibernate bindings, drivers, etc,

Can you create multiple catalogs in H2?

耗尽温柔 提交于 2019-12-10 20:26:45
问题 When you connect to an embedded local H2 database like so: jdbc:h2:./target/data/CATALOGA; H2 uses the database name (CATALOGA here) as the CATALOG_NAME. This can be seen by querying the INFORMATION_SCHEMA.CATALOGS table. Is it possible to have more than one catalog? You cannot insert into the INFORMATION_SCHEMA and H2 does not allow for CREATE CATALOG statements. Background information is that we have queries that join across catalogs. So something that looks like: select * from CATALOGA.dbo

Using Spring, why can H2 transaction rollback work correctly in embedded-database mode, but not in server mode?

落花浮王杯 提交于 2019-12-10 18:09:30
问题 A simple spring service with method doing insert and throwing Runtime exception after insert. Runtime exception should cause rollback. @Transactional() public void insertAndThrowRuntimeEx() { Order order = new Order(); entityManager.persist(order); throw new RuntimeException("Unexpected runtime exception"); } Rollback appears correctly only when I configure dataSource with: <jdbc:embedded-database id="dataSource" type="H2" /> <!-- with this configuration there is correct rollback --> But when

Transition H2 data to PostgreSQL

送分小仙女□ 提交于 2019-12-10 17:54:19
问题 I am doing a transition from H2 database to PostgreSQL. As I found out - the SQL dump which is created when doing SCRIPT TO command on H2 contains several inappropriate constructions: Unicode data is wrapped with function STRINGDECODE('unicode-data') Binary & Blob data is escaped as X'binary-data' - probably hex format (Used for storing images and files directly in a database table I managed to change my exported SQL so it is compatible with Postgres as follows: Unicode data is wrapped with E

How to access CSV file within WAR using H2's CSVREAD() function/query?

筅森魡賤 提交于 2019-12-10 17:33:13
问题 I'm trying to read a CSV file from within a web application (Tomcat 5.5.x) and all I get is 'FileNotFoundExceptions's: dbStatement.executeQuery("SELECT * FROM CSVREAD('csvfile.csv');"); I don't think I can/need to specify an absolute path (it will be deployed into a Linux/Tomcat server I won't have access to) and am unsure of the file protocol necessary ('jar:file', classpath: etc). The file is under "**/WEB-INF/classes/csvfile.csv" Any ideas on the structure of the path I need to pass to

How to run 2 SQL “SELECT”s atomically? Or any other better way to get number of rows before i process them

不问归期 提交于 2019-12-10 17:17:17
问题 I'm trying to run atomically ResultSet resSet; resSet = statement.executeQuery("SELECT COUNT(*) FROM table"); resSet.next() long rowCount = resSet.getLong(1); resSet = statement.executeQuery("SELECT * FROM table"); // read data of known row count... My question is what is the best way? Currently I found out I can do: connection.setAutoCommit(false); connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE) // call 2 SQL queries above connection.commit(); This way seems to work.

Table creation fails

爱⌒轻易说出口 提交于 2019-12-10 17:11:47
问题 I'm using an H2 database for testing my Grails app. I have some simple domain classes like: package mypackage class UserSession { User user String sessionTokenHash // last seen info String lastSeenIP Date lastSeenTime String lastSeenUserAgent String lastSeenURL } however, the table doesn't seem to get created correctly. hbm2ddl.SchemaExport Unsuccessful: create table user_session (id bigint not null auto_increment, version bigint not null, last_seenip varchar(255) not null, last_seen_time