h2

Spring’s embedded H2 datasource and DB_CLOSE_ON_EXIT

 ̄綄美尐妖づ 提交于 2019-11-30 11:18:27
问题 For unit tests (call them integration tests if you want) I have configured an embedded database in my Spring config like so: <jdbc:embedded-database id="dataSource" type="H2"> <jdbc:script location="classpath:schema_h2.sql" /> </jdbc:embedded-database> Now, when running the tests from the command line, they work fine, but I get some errors at the end (harmless, but irritating): WARN 2013-03-25 12:20:22,656 [Thread-9] o.s.j.d.e.H2EmbeddedDatabaseConfigurer 'Could not shutdown embedded database

Error using Hibernate with H2 in memory database

倖福魔咒の 提交于 2019-11-30 08:33:57
I'm working with Hibernate. How can I configure my persistence.xml to have an H2 in-memory database? My persistence.xml is: <?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL"> <class>com.mastertheboss.domain.Employee</class> <class>com.mastertheboss.domain.Department</class> <properties>

H2 Database multiple connections

帅比萌擦擦* 提交于 2019-11-30 08:22:43
问题 I have the following issue: Two instances of an application on two different systems should share a small database. The main problem is that both systems can only exchange data through a network-folder. I don't have the possibilty to setup a database-server somewhere. Is it possible to place a H2 database on the network-folder and let both instances connect to the database (also concurrently)? I could connect with both instances to the db using the embedded mode if I disable the file-locking,

Convert MySQL script to H2

我的未来我决定 提交于 2019-11-30 08:10:01
I have an init script for my MySQL database but for test purposes I wan't to use a H2 database. Anyone knows how to convert the file or at least has a list of the syntax differences ? thanks. Thomas Mueller There are a number of database tools that help migrating data from one to another database, for example: Flyway SQuirreL DB Copy Plugin Here is a good instruction by Matthew Casperson Exporting from MySQL to H2 Here is a short list of steps, to convert from mysql to h2: Fix up single quotes CREATE TABLE `user` ( `name` varchar(20) NOT NULL, convert to CREATE TABLE user ( name varchar(20)

jQuery load() 方法实现加载远程数据

↘锁芯ラ 提交于 2019-11-30 06:27:39
jQuery load() 方法是简单但强大的 AJAX 方法。 load() 方法从服务器加载数据,并把返回的数据放入被选元素中。 语法: $(selector).load(URL,data,callback); 必需 的 URL 参数规定您希望加载的 URL。可选的 data 参数规定与请求一同发送的查询字符串键/值对集合。可选的 callback 参数是 load() 方法完成后所执行的函数名称。 这是示例文件("demo_test.txt")的内容: <h2>jQuery and AJAX is FUN!!!</h2> <p id="p1">This is some text in a paragraph.</p> 下面的这句话会把文件 "demo_test.txt" 的内容加载到指定的 <div> 元素中: $("#div1").load("demo_test.txt"); 也可以把 jQuery 选择器添加到 URL 参数。 下面的例子把 "demo_test.txt" 文件中 id="p1" 的元素的内容,加载到指定的 <div> 元素中: $("#div1").load("demo_test.txt #p1"); 可选的 callback 参数规定当 load() 方法完成后所要允许的回调函数。回调函数可以设置不同的参数: •responseTxt -

Java实现哈希表

陌路散爱 提交于 2019-11-30 05:43:47
Java实现哈希表 基本概念 哈希表 :Hash Table,也称为散列表。在待存放的数据中定义一个关键字k,通过一个映射关系f,将k映射到一个地址中,这个地址称为散列地址。之后查找该记录时,不用再通过数据对比来查找,而直接使用这条记录的关键字k映射获取数据存放地址,取出该地址数据即可。通过这种方式来存放数据的地址集称为哈希表(散列表)。哈希表下维护了一个数组,数组的索引就是我们要映射得到的地址。 散列函数 :将数据的关键字k映射为地址的对应关系f称为散列函数。 冲突 :不同的关键字通过同一散列函数f映射的结果相同,即f(k1)=f(k2),这种现象称为冲突,k1和k2称作同义词。 负载因子 :负载因子=表中现有数据个数/数组总容量,哈希表维护的是数组,因此我们需要在适当的时候对表进行扩容,这个负载因子就是衡量是否需要扩容,也就是说,当我们规定负载因子为0.75,那么我们每次插入数据时,都可计算负载因子是否大于0.75,若大于,则进行扩容。 设计散列函数 1. 直接寻址法 例如:我们要往哈希表中存放员工的信息,我们就可以直接用员工的年龄来作为散列地址,即f(key)=key;或者我们知道员工的出生年份1980,我们可以用2019-1980作为散列地址,即f(key)=2019-key。也就是说,我们可以取关键字的某个线性函数值为散列地址: f(key)=a · key+b

常见排序算法及对应的时间复杂度和空间复杂度

倾然丶 夕夏残阳落幕 提交于 2019-11-30 04:03:20
本人免费整理了Java高级资料,涵盖了Java、Redis、MongoDB、MySQL、Zookeeper、Spring Cloud、Dubbo高并发分布式等教程,一共30G,需要自己领取。 传送门: https://mp.weixin.qq.com/s/JzddfH-7yNudmkjT0IRL8Q 排序算法经过了很长时间的演变,产生了很多种不同的方法。对于初学者来说,对它们进行整理便于理解记忆显得很重要。每种算法都有它特定的使用场合,很难通用。因此,我们很有必要对所有常见的排序算法进行归纳。 排序大的分类可以分为两种:内排序和外排序。在排序过程中,全部记录存放在内存,则称为内排序,如果排序过程中需要使用外存,则称为外排序。下面讲的排序都是属于内排序。 内排序有可以分为以下几类:   (1)、插入排序:直接插入排序、二分法插入排序、希尔排序。   (2)、选择排序:直接选择排序、堆排序。   (3)、交换排序:冒泡排序、快速排序。   (4)、归并排序   (5)、基数排序 表格版 ① 插入排序 •思想:每步将一个待排序的记录,按其顺序码大小插入到前面已经排序的字序列的合适位置,直到全部插入排序完为止。 •关键问题:在前面已经排好序的序列中找到合适的插入位置。 •方法: –直接插入排序 –二分插入排序 –希尔排序 (1)直接插入排序(从后向前找到合适位置后插入) 1、基本思想

Spring + JUnit + H2 + JPA : Is it possible to drop-create the database for every test?

本小妞迷上赌 提交于 2019-11-30 03:51:22
问题 To keep the independency between the JUnit tests, I need to create the database at the beginning of every test, and destroy it at the end of every test. The database should be created in memory ( H2 database ) by executing SQL queries that exist in a SQL file (Native insert queries...). Defining my keys-values in a properties file and respecting JPA specification (persistence.xml), how can I create-drop database for every JUnit test using annotations/injections? Thank you a lot! 回答1: You

H2 SQL Grammar Exception

偶尔善良 提交于 2019-11-30 03:22:00
问题 I am trying to import a sql script for H2. This script is provided by spring-batch and it's used to store the jobs metadata. When I execute this script directly in the H2 console, I have no syntax errors, but I referenced the same script in Hibernate/JPA to be imported at the initialization phase, I got this exception : org.hibernate.tool.hbm2ddl.ImportScriptException: Error during statement execution (file: 'org/springframework/batch/core/schema-h2.sql'): CREATE TABLE BATCH_JOB_INSTANCE ( ..

Where are my H2 database files?

梦想的初衷 提交于 2019-11-30 03:15:50
I'm just evaluating the H2 database... I downloaded and unpacked the installation and connect to a database at jdbc:h2:file:/home/konrad/test . /home/konrad is my home dir, test does not exist (I expect H2 to create it). The console seems to work OK. I created a table and inserted a row to it. Even if I disconnect and reconnect the console, I can see and query the table. However, I don't see the file I expected. Where is it? Are you sure there is no: /home/konrad/test.h2.db file? If not, try this: $ lsof -p `jps -ml | grep h2 | cut -d' ' -f1` | grep \.h2\.db$ What it does is it look for Java