Environment: Spring(3.2.3.RELEASE) + MyBatis(3.2.2) + HSQL(2.3.0)
<resultMap id="hashMapResult" type="java.util.HashMap">
    <result property="key" column="key" />
    <result property="value" column="value" />
</resultMap>
<select id="getSettings" resultMap="hashMapResult">
    SELECT "KEY","VALUE" from "PUBLIC"."SETTINGS";
</select>
     create table "SETTINGS" (
    "KEY" varchar(255) not null,
    "VALUE" varchar(512) not null,
    CONSTRAINT SETTINGS_KEY_UNIQUE UNIQUE("KEY")
     );
URL: jdbc:hsqldb:mem:mydb;sql.syntax_mys=true;shutdown=true;
When using memory database, the following errors appeared:
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: SETTINGS
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
at org.hsqldb.SchemaManager.getTable(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
at org.hsqldb.ParserDQL.readTableName(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source) ~[hsqldb-2.3.0.jar:2.3.0]
But when using file-based database jdbc:hsqldb:file:mydb;sql.syntax_mys=true;shutdown=true; no errors at all.
I am using Spring's EmbeddedDatabaseFactory to init the database:
    try {
        EmbeddedDatabaseFactory dbFactory = new EmbeddedDatabaseFactory();
        DatabaseConfig dbConfig = appConfig.getDbConfig();
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
        populator.setContinueOnError(false);
        populator.setIgnoreFailedDrops(false);
        DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
        populator.addScript(resourceLoader.getResource(dbConfig
                .getSqlSchemeFile()));
        populator.addScript(resourceLoader.getResource(dbConfig
                .getSqlDataFile()));
        dbFactory.setDatabasePopulator(populator);
        dbFactory.setDatabaseName(dbConfig.getName());
        dbFactory.setDatabaseConfigurer(new HSQLConfigurer(dbConfig));
        return dbFactory.getDatabase();
    } catch (Exception e) {
        logger.error("dataSource error", e); //$NON-NLS-1$
        return null;
    }
Anyone knows why?
HSQLDB (HyperSQL Database) HSQLDB is an open source project, also written in Java, representing a relational database. It follows the SQL and JDBC standards and supports SQL features such as stored procedures and triggers. It can be used in the in-memory mode, or it can be configured to use disk storage.
HSQLDB (HyperSQL DataBase) is the leading SQL relational database system written in Java. It offers a small, fast multithreaded and transactional database engine with in-memory and disk-based tables and supports embedded and server modes. It includes a powerful command line SQL tool and simple GUI query tools.
You shouldn't use shutdown=true in this context. It seems the connection is closed and the database is shutdown, which means the memory database no longer exists.
You should also avoid using VALUE as a column name. This is a keyword.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With