h2

How can I connect with an SQL tool to an embedded h2 db?

安稳与你 提交于 2019-12-03 22:02:17
I have a simple h2 database example, I assume it is a database that is stored in a single file. But where do I find this file? I'd like to connect to that db using SQL clients like Squirrel. Where is this file placed by default? <property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.H2Platform" /> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> <property name="javax.persistence.jdbc.url" value="jdbc:h2:~/myDB;FILE_LOCK=NO" /> <property name="javax.persistence.jdbc.user" value="sa" /> <property name="javax.persistence.jdbc.password"

JPA Referential integrity constraint violation oneToMany and bulk manipulation query

 ̄綄美尐妖づ 提交于 2019-12-03 18:29:32
My domain model diagram looks like this: As you can see I have an oneToMany releation between Student and Attendance and between Attendance and Seminar. Below are the Student and Attendance Classes, as well as my helper class( Initializer). package com.seminars.domain; import java.util.Calendar; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany;

php接口安全设计浅谈

怎甘沉沦 提交于 2019-12-03 18:18:20
php接口安全设计浅谈 接口的安全性主要围绕Token、Timestamp和Sign三个机制展开设计,保证接口的数据不会被篡改和重复调用,下面具体来看: (1)Token授权机制 :( Token是客户端访问服务端的凭证)-- 用户使用用户名密码登录后服务器给客户端返回一个Token( 通常是UUID ),并将Token-UserId以键值对的形式存放在缓存服务器中。服务端接收到请求后进行Token验证,如果Token不存在,说明请求无效。 (2)时间戳超时机制 :( 签名机制保证了数据不会被篡改 )用户每次请求都带上当前时间的时间戳timestamp,服务端接收到timestamp后跟当前时间进行比对,如果时间差大于一定时间( 比如5分钟 ),则认为该请求失效。 时间戳超时机制是防御DOS攻击的有效手段。 (3)签名机制 :将 Token 和 时间戳 加上其他请求参数再用MD5或SHA-1算法(可根据情况加点盐)加密,加密后的数据就是本次请求的签名sign,服务端接收到请求后以同样的算法得到签名,并跟当前的签名进行比对,如果不一样,说明参数被更改过,直接返回错误标识。 /** * @desc 接受参数处理 */ private function dealParam(){ //接受header参数--系统参数 $systemParam=getAllHeadersParam(); /

Any ideas for persisting H2 Database In-Memory mode transaction?

≡放荡痞女 提交于 2019-12-03 17:10:23
The following code for H2 database with "in-memory mode" runs perfectly fine until connection is open or VM is running. But H2 db loses data when connection is closed or when VM shutdown takes place. Is there any other way to persist data across multiple startup-shutdown/online-offline cycles ? One way would be to create diskbased replica of in-memory database by tracking DDLs and DMLs issued from application and a sync process in background that checks for integrity of data on disk and memory. Diskbased DMLs might be slower + additional overhead of copying/loading disk data to memory on each

How to write sql query whose conditions are optional?

百般思念 提交于 2019-12-03 16:42:54
I have to write a query where conditional parameters are not known because they are set dynamically in jdbc. And those conditions should be optional. I use h2 database. The query is : select e.event_id,a.attempt_id,a.preferred,a.duration,a.location from event e,attempt a where e.user_label=? and e.start_time=? and e.end_time=? and e.duration_min=? and e.duration_max=? and e.event_id=a.event_id But how to make these conditions optional except using OR because params are not known? Thanks! dasblinkenlight If you can switch to named parameters , you could change the condition to to check

How to find the active number of open database connections in H2/MySQL

守給你的承諾、 提交于 2019-12-03 13:34:15
How to find the active number of open database connections in H2/MySQL. We need this information to identify if there are any connection leaks. For H2, use: select * from information_schema.sessions; For MySQL, use: show full processlist; or select * from information_schema.processlist; If you are just interested in the session count, use select count(*) instead of select * 来源: https://stackoverflow.com/questions/6137683/how-to-find-the-active-number-of-open-database-connections-in-h2-mysql

IF function in H2 for MySQL compatibility

别来无恙 提交于 2019-12-03 12:17:36
I'm using H2 (with MySQL compatibility mode) to write some automated tests against our software that uses MySQL. Unfortunately, it seems like H2 does not have have the IF function that many of our queries use. Short of rewriting our application queries with something like DECODE, is their a good way to create the if function, say as an Alias? The error that I'm getting: WARNING: Failed to execute: SELECT IF(true,'TRUE!!','FALSE!!!') because: Function "IF" not found; SQL statement: Ended up just rewriting queries to use functions compatible with both database - H2, MySql. In my case, the

How reliable is h2 database? [closed]

孤街醉人 提交于 2019-12-03 10:32:13
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 10 months ago . When I ask this question, I see that the current version of H2 database was released on 07-01-2011 (very recently). That is very good & healthy. Will this pace be kept? event if the pace of new releases are slow, will it be supported by opensource community for long term?

H2 createTcpServer() does not create server?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: after reading the H2 documentation , I wrote this simple application to create a H2 database in a local directory: public static void main(String[] args) throws SQLException { String path = "C:/Temp/H2/"; File fpath = new File(path); fpath.mkdirs(); FileUtils.recursiveDelete(fpath); String dbName = "tata"; String connection = "jdbc:h2:file:" + path + dbName; Server server = Server.createTcpServer(connection); server.start(); server.stop(); } This program runs fine, but when I check in the target directory, the database is not there... (i am

Make H2 treat quoted name and unquoted name as the same

£可爱£侵袭症+ 提交于 2019-12-03 09:55:01
H2 seems to make a difference between name with quote and name without quote. Is there a way to make it treat them the same way? Here's the tests that I've done : CREATE TABLE test (dummy INT); CREATE TABLE "testquote" (dummy INT, "quotedDummy" INT); Here are the queries : SELECT * FROM test; --work SELECT * FROM "test"; -- doesn't work SELECT * FROM "testquote"; --work SELECT * FROM testquote; --doesn't work SELECT dummy FROM "testquote"; --work SELECT quotedDummy FROM "testquote"; --doesn't work SELECT "quotedDummy" FROM "testquote"; --work What can I do to make those queries work with H2?