hsqldb

Where can I see the HSQL database and tables

断了今生、忘了曾经 提交于 2019-11-28 01:38:08
问题 I have downloaded a hsqldb.jar and I set to project buildpath,then next I wrote the program Class.forName("org.hsqldb.jdbc.JDBCDriver"); Connection conn = DriverManager.getConnection( "jdbc:hsqldb:mem:mydb", "SA", ""); String bookTableSQL = "create table MY_TABLE ("+ " TITLE varchar(256) not null primary key,"+ " AUTHOR varchar(256) not null"+ ");"; Statement st = conn.createStatement(); st.execute(bookTableSQL); System.out.println(st); String sql = "INSERT INTO MY_TABLE " + "VALUES ('Mahnaz'

File based h2 persisted but not loaded in Spring Boot

早过忘川 提交于 2019-11-27 23:24:27
问题 I made a small application based on Spring Boot: spring-boot-starter-web spring-boot-starter-data-jpa The application has simply one domain class Post.java . Accordingly there is a RestController and a DAO. The data is supposed to be persisted in a file based hsql db. When the application is running everything seems fine. Data is stored. The h2 file is created and contains insert statements. However, when I kill the application and start it a second time. No data is loaded. (As if a brand new

EntityManager does not write to database

喜你入骨 提交于 2019-11-27 23:18:33
i just set up a so far still quite minimal project maven/jpa/hibernate project, where i am trying to persist an object. My class is a quite simple one: @Entity public class Person { @Id @GeneratedValue private int id; private String name; } My persistence.xml is very basic as well: <persistence xmlns="http://java.sun.com/xml/ns/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"> <persistence-unit name="Fahrplan_v2"> <class>model.Person</class>

Cause of No suitable driver found for

半城伤御伤魂 提交于 2019-11-27 20:32:33
问题 I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overridden the configLocations as follows: protected String[] getConfigLocations(){ return new String[] {"classpath:company/dc/test-context.xml"}; } My test-context.xml file is defined as follows: <beans xmlns="http://www.springframework.org/schema/beans

How do you reset Spring JUnit application context after a test class dirties it?

こ雲淡風輕ζ 提交于 2019-11-27 19:58:09
I'm using Spring 3.1.1.RELEASE, JUnit 4.8.1 and the HSQL 2.7.7 in-memory database. I have one test class annotated as @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "classpath:test-trainingSessionServiceContext.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class TrainingSessionServiceTest { The problem is, when I run "mvn clean test", it seems that all test classes run after the above class fail because the in-memory database is destroyed and not re-created. I get errors like org.hibernate.exception.SQLGrammarException: user lacks privilege or

Unsuccessful: alter table XXX drop constraint YYY in Hibernate/JPA/HSQLDB standalone

主宰稳场 提交于 2019-11-27 17:31:05
I am trying to run some Hibernate/JPA examples using an in-memory HSQL DB. The error message I get is the following: 13:54:21,427 ERROR SchemaExport:425 - HHH000389: Unsuccessful: alter table ReferringItem_map drop constraint FK5D4A98E0361647B8 13:54:21,427 ERROR SchemaExport:426 - user lacks privilege or object not found: PUBLIC.REFERRINGITEM_MAP 13:54:21,427 ERROR SchemaExport:425 - HHH000389: Unsuccessful: alter table ReferringItem_myCollection drop constraint FK75BA3266361647B8 13:54:21,427 ERROR SchemaExport:426 - user lacks privilege or object not found: PUBLIC.REFERRINGITEM_MYCOLLECTION

View content of H2 or HSQLDB in-memory database

家住魔仙堡 提交于 2019-11-27 17:00:58
Is there a way to browse the content of an H2 or an HSQLDB in-memory database for viewing? For example, during a debugging session with Hibernate in order to check when the flush is executed; or to make sure the script that instantiates the DB gives the expected result. Does it exist an addon or a library that you can embed with your code in order to allow this? Please, mention which one you're talking about (H2 or HSQLDB) in case you have an answer specific to one of them. Tomasz Nurkiewicz You can run H2 web server within your application that will access the same in-memory database. You can

How to initialize in-memory HSQLDB using script via Spring

◇◆丶佛笑我妖孽 提交于 2019-11-27 09:25:43
问题 I am attempting to do unit testing of my DAO (using Spring and Hibernate). I am using HSQLDB per this tutorial. The tutorial states that the in-memory HSQLDB database can be initialized using a SQL script but I cannot find information on how to do so in Spring. Here is the pertinent Spring context config: <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> <property name="url" value="jdbc:hsqldb:mem:mydb" />

how to return last inserted (auto incremented) row id in HSQL?

≯℡__Kan透↙ 提交于 2019-11-27 07:55:41
问题 i am working with HSQL database for testing purpose. i want standalone db file. but now i am in trouble to get last inserted row id (auto-incremental - identity) in HSQL. how can i get id?? 回答1: It's pretty hard to write a query to perform this when you haven't given your table schema, but something like the following: SELECT TOP 1 Id FROM [TABLENAME] ORDER BY Id DESC 回答2: http://www.hsqldb.org/doc/guide/ch09.html the last inserted value into an identity column for a connection is available

SQL - Add up all row-values of one column in a singletable

随声附和 提交于 2019-11-27 06:38:43
问题 I've got a question regarding a SQL-select-query: The table contains several columns, one of which is an Integer-column called "size" - the task I'm trying to perform is query the table for the sum of all rows (their values), or to be more exact get a artifical column in my ResultSet called "overallSize" which contains the sum of all "size"-values in the table. Preferable it would be possible to use a WHERE-clause to add only certain values ("WHERE bla = 5" or something similar). The DB