Last active
April 16, 2018 16:37
-
-
Save theotherian/6096578 to your computer and use it in GitHub Desktop.
hsqldb basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An example of creating an in-memory HSQLDB server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8'?> | |
<!DOCTYPE hibernate-configuration PUBLIC | |
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" | |
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> | |
<hibernate-configuration> | |
<session-factory> | |
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property> | |
<!-- set url to target/hsql:mem:test so that files are written to build dir --> | |
<property name="connection.url">jdbc:hsqldb:target/hsql:mem:test</property> | |
<property name="connection.username">sa</property> | |
<property name="connection.password"></property> | |
<property name="connection.pool_size">1</property> | |
<property name="dialect">org.hibernate.dialect.HSQLDialect</property> | |
<property name="current_session_context_class">thread</property> | |
</session-factory> | |
</hibernate-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.hsqldb.server.Server; | |
public class ServerApplication { | |
public static void main(String[] args) throws Exception { | |
Server server = new Server(); | |
server.setDatabaseName(0, "test"); | |
// set location to target/mem:test so that files are written to build dir | |
server.setDatabasePath(0, "target/mem:test"); | |
server.setSilent(false); | |
server.setTrace(true); | |
server.start(); | |
// do stuff | |
server.shutdown(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment