Package org.tmatesoft.sqljet.core.table

Examples of org.tmatesoft.sqljet.core.table.SqlJetDb


        Assert.assertFalse(false);
    }

    @Test
    public void createIndexRepCache() throws SqlJetException, FileNotFoundException, IOException {
        final SqlJetDb repCache = SqlJetDb.open(copyFile(new File(REP_CACHE_DB), DELETE_COPY), true);
        repCache.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                db.createIndex("CREATE INDEX rep_cache_test_index ON " + REP_CACHE_TABLE
                        + "(hash, revision, offset, size, expanded_size);");
                final ISqlJetTable openTable = repCache.getTable(REP_CACHE_TABLE);
                openTable.insert("test", 1, 2, 3, 4);
                return null;
            }
        });
    }
View Full Code Here


        });
    }

    @Test
    public void createTableRepCache() throws SqlJetException, FileNotFoundException, IOException {
        final SqlJetDb repCache = SqlJetDb.open(copyFile(new File(REP_CACHE_DB), DELETE_COPY), true);
        repCache.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                final ISqlJetTable openTable = repCache.getTable(createTable.getName());
                logger.info(createTable.toString());
                openTable.insert(null, "test");
                db.createIndex("CREATE INDEX test_index ON test(name);");
                openTable.insert(null, "test1");
                return null;
View Full Code Here

        });
    }

    @Test
    public void dropTableRepCache() throws SqlJetException, FileNotFoundException, IOException {
        final SqlJetDb repCache = SqlJetDb.open(copyFile(new File(REP_CACHE_DB), DELETE_COPY), true);
        repCache.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                db.dropTable(REP_CACHE_TABLE);
                return null;
            }
        });
        final ISqlJetTableDef openTable = repCache.getSchema().getTable(REP_CACHE_TABLE);
        Assert.assertNull(openTable);
    }
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                logger.info(createTable.toString());
                db.createIndex("CREATE INDEX test_index ON test(name);");
                final ISqlJetTable openTable = createDb.getTable(createTable.getName());
                openTable.insert(null, "test");
                openTable.insert(null, "test1");
                return null;
            }
        });
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.getOptions().setEncoding(SqlJetEncoding.UTF16LE);
        createDb.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                logger.info(createTable.toString());
                db.createIndex("CREATE INDEX test_index ON test(name);");
                final ISqlJetTable openTable = createDb.getTable(createTable.getName());
                openTable.insert(null, "test");
                openTable.insert(null, "test1");
                try {
                    openTable.insert(null, new String(TEST_UTF8, "UTF8"));
                } catch (UnsupportedEncodingException e) {
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        db.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                logger.info(createTable.toString());
                db.createIndex("CREATE INDEX test_index ON test(name);");
                final ISqlJetTable openTable = createDb.getTable(createTable.getName());
                openTable.insert(null, "test");
                openTable.insert(null, "test1");
                try {
                    openTable.insert(null, new String(TEST_UTF8, "UTF8"));
                } catch (UnsupportedEncodingException e) {
                    throw new SqlJetException(e);
                }
                createDb.getOptions().setEncoding(SqlJetEncoding.UTF16LE);
                return null;
            }
        });
    }
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                createDb.getOptions().setCacheSize(1000);
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                logger.info(createTable.toString());
                db.createIndex("CREATE INDEX test_index ON test(name);");
                final ISqlJetTable openTable = createDb.getTable(createTable.getName());
                openTable.insert(null, "test");
                openTable.insert(null, "test1");
                try {
                    openTable.insert(null, new String(TEST_UTF8, "UTF8"));
                } catch (UnsupportedEncodingException e) {
                    throw new SqlJetException(e);
                }
                return null;
            }
        });

        createDb.close();

        final SqlJetDb openDb = SqlJetDb.open(createFile, true);
        final int cacheSize = openDb.getOptions().getCacheSize();
        Assert.assertEquals(1000, cacheSize);

    }
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.getOptions().setAutovacuum(true);
        createDb.getOptions().setIncrementalVacuum(true);
        createDb.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {

                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                logger.info(createTable.toString());
                db.createIndex("CREATE INDEX test_index ON test(name);");
                final ISqlJetTable openTable = createDb.getTable(createTable.getName());
                openTable.insert(null, "test");
                openTable.insert(null, "test1");
                try {
                    openTable.insert(null, new String(TEST_UTF8, "UTF8"));
                } catch (UnsupportedEncodingException e) {
                    throw new SqlJetException(e);
                }
                return null;
            }
        });

        createDb.close();

        final SqlJetDb checkDb = SqlJetDb.open(createFile, true);
        Assert.assertTrue(checkDb.getOptions().isAutovacuum());
        Assert.assertTrue(checkDb.getOptions().isIncrementalVacuum());
        checkDb.close();

        SqlJetFileUtil.deleteFile(createFile);

    }
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                createDb.getOptions().setSchemaVersion(123);
                return null;
            }
        });
        createDb.close();

        final SqlJetDb openDb = SqlJetDb.open(createFile, true);
        final int schemaVersion = openDb.getOptions().getSchemaVersion();
        Assert.assertEquals(123, schemaVersion);

    }
View Full Code Here

        final File createFile = File.createTempFile(SCHEMA_TEST, null);
        if (DELETE_COPY)
            createFile.deleteOnExit();

        final SqlJetDb createDb = SqlJetDb.open(createFile, true);
        createDb.getOptions().setFileFormat(ISqlJetLimits.SQLJET_MIN_FILE_FORMAT);
        createDb.close();

        final SqlJetDb openDb = SqlJetDb.open(createFile, true);
        final int fileFormat = openDb.getOptions().getFileFormat();
        Assert.assertEquals(ISqlJetLimits.SQLJET_MIN_FILE_FORMAT, fileFormat);

    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.table.SqlJetDb

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.