h2

problem with INIT=RUNSCRIPT and relative paths

两盒软妹~` 提交于 2019-11-30 01:13:53
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 ? Thanks You can use the following url: "jdbc:h2:mem:sample;INIT=RUNSCRIPT FROM 'classpath:scripts

DIV+CSS忽悠前端小白

China☆狼群 提交于 2019-11-30 01:04:50
在大约两年前,DIV+CSS是一对很诱人的组合,会用DIV+CSS制作网页的人,常常会被人赞以大拇指的,记得06年初的时候,我用 div+css布局的一个纯静态网站还拿了学校网页设计比赛的一个奖。 今天,尽管提到DIV+CSS,还会有很多人热情高涨,但是我会对他 摇头了:DIV+CSS不是一切,更不是某些人所谓的“神话”!创造神话的是CSS,不是DIV+CSS。我想,是时候纠正这个问题了。 CSS 的要义,是各个标签要各尽所用。 盲目推崇DIV+CSS只会让小白误入歧途的。 1、DIV只是HTML最常用的标签之一 显 然HTML并不只是一个DIV标签有用,每个标签都有它的用途,只是DIV是其中最有用的一个罢了。如果DIV可以实现所有其它标签的功能,那么W3C早 就把HTML精简了! Table也不是一无是处,只是用table比较简单、容易上手才在早期被人错误的广泛推广。但是table在处理网 页数据的表现上,是其他标签无法替代的,只是,它不适合用来做整个页面的布局。 2、代码的可读性 纯DIV+CSS的网站 的代码的可读性无疑是非常差的,甚至table还可以通过tr和td来区分行和列,一堆DIV堆砌在一起,如果没有注释,你根本不知道某个部分是做什么用 的。 3、语义化与结构化 现在,在开发CSS的时候,提的越来越多的是语义化,语义化归根到底其实还是代码的可读性问题。

java ClassNotFoundException for org.h2.Driver

老子叫甜甜 提交于 2019-11-30 00:12:47
问题 I am trying to use H2 to connect to a database in Java (using Eclipse as the IDE). The sample does (below) throws a ClassNotFoundException . The thing is, I did add the h2 jar file to the system CLASSPATH. I have even checked it's there several times via printenv in the console. Am I omitting a step? CODE: import java.sql.*; public class Program { /** * @param args */ public static void main(String[] args) throws Exception{ try{ System.out.println("hello, world!"); Class.forName("org.h2

Is SQLite the most appropriate thing to use for an embedded database? [duplicate]

↘锁芯ラ 提交于 2019-11-29 23:13:06
问题 This question already has an answer here: Java and SQLite [closed] 10 answers I need to build a Java application that I will install on a Linux server. When people will install they just would need to install this application, launch it, and nothing more. But we have some data to save. I said no to MySQL, because it needs a server. I said no to XML because there will be really a lot of data to save and manipulate. So I'm looking at SQLite which is the best I think. Indeed (stop me if i'm

auto increment ID in H2 database

眉间皱痕 提交于 2019-11-29 22:48:58
Is there a way to have an auto_incrementing BIGINT ID for a table. It can be defined like so id bigint auto_increment but that has no effect (it does not increment automatically). I would like to insert all fields but the ID field - the ID field should be provided by the DBMS. Or do I need to call something to increment the ID counter? It works for me. JDBC URL: jdbc:h2:~/temp/test2 drop table test; create table test(id bigint auto_increment, name varchar(255)); insert into test(name) values('hello'); insert into test(name) values('world'); select * from test; result: ID NAME 1 hello 2 world

Connect remotely to an H2 Database using a Java Application

时间秒杀一切 提交于 2019-11-29 22:24:36
问题 I'm having the following problem: When I try to createTcpServer with my external IP address (the PC's IP and not my local IP = the one we see as an output after running ipconfig in cmd.exe) the following error occurs: Error with Server: Exception opening port "9092" (port may be in use), cause: "java.net.BindException: Cannot assign requested address: JVM_Bind" [90061-169] However, the port is not in use. I've checked that using netstat -a -n . I have enabled my external IP and I have

spring boot整合H2数据库

若如初见. 提交于 2019-11-29 19:28:24
一、背景: 1、H2数据库是一个开源的关系型数据库。H2是一个嵌入式数据库引擎,采用java语言编写,不受 平台的限制,同时支持网络版和嵌入式版本,有比较好的兼容性,支持相当标准的sql标准,支持集群。 2、提供JDBC、ODBC访问接口,提供了非常友好的基于web的数据库管理界面 二、引入h2的依赖包 <!-- https://mvnrepository.com/artifact/com.h2database/h2 --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.199</version> </dependency> 三、常用配置 #h2配置 #启用SQL语句的日志记录 spring.jpa.show-sql = true #设置ddl模式 spring.jpa.hibernate.ddl-auto = update ##数据库连接设置 spring.datasource.driverClassName =org.h2.Driver #spring.datasource.url = jdbc:h2:mem:dbc2m #Windows当前用户路径 #spring.datasource.url = jdbc:h2:file:~/.h2/dbc2m

h2.db file keeps growing

佐手、 提交于 2019-11-29 18:24:19
We're using H2 database (persistent) embedded within our application. Even after we delete the tables, the h2.db file keeps growing. We tried disabling transaction isolation (LOCK_MODE=0), disabled the query log (TRACE_LEVE_FILE=0), disabled the undo log, but nothing helps. Is compacting the only option? Compacting will need restart of the DB which we cannot do. Using TRACE_LEVE_FILE=0 will only affect the file {databaseName}.trace.db , I suggest not to use disable tracing. The file {databaseName}.trace.db contains human readable error messages and warnings, and normally should be empty. If it

Start and setup in-memory DB using Spring

元气小坏坏 提交于 2019-11-29 17:37:31
问题 I'm writing a small demo application in Java using Spring, that needs to have access to a database. It should run on different machines and it would be far too much effort to setup a real database. Therefore I want to use an embedded one. The DB has a given schema (two tables) and some (very few) pre-defined entries. I'm looking for a simple way to start an in-memory database, create the tables and fill in the data. All of this should happen while initializing the Spring context. My approach

Saving in-memory H2 database to disk

佐手、 提交于 2019-11-29 16:58:37
问题 How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading. I want to use this for caching data so I don't have to run all the lines of create table/insert clauses every time. 回答1: Instead of using an in-memory database, you could use a regular (persisted) database. You can still use in-memory tables even then (create memory table). The easiest way to persist a completely in-memory database to disk is to use the SCRIPT TO 'fileName' SQL