Package org.tmatesoft.sqljet.core.table

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


        Assert.assertNull(openTable);
    }

    @Test
    public void dropIndex() throws SqlJetException {
        db.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                db.dropIndex("test1_name_index");
                db.dropIndex("test1_value_index");
                return null;
View Full Code Here


        Assert.assertNull(db.getSchema().getIndex("test1_value_index"));
    }

    @Test
    public void dropAll() throws SqlJetException {
        db.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                // /Set<String> indices = db.getSchema().getIndexNames();
                Set<String> tables = db.getSchema().getTableNames();
                for (String tableName : tables) {
                    ISqlJetTableDef tableDef = db.getSchema().getTable(tableName);
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);");
View Full Code Here

        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);");
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);");
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());
View Full Code Here

            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());
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;
            }
        });
View Full Code Here

    }

    @Test(expected = SqlJetException.class)
    public void createIndexUniqueFail() throws SqlJetException {
        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());
                final ISqlJetIndexDef createIndex = db.createIndex("create unique index index_test_text on test(name)");
                logger.info(createIndex.toString());
                return null;
            }
        });
        db.close();
        db.open();
        db.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTable openTable = db.getTable("test");
                openTable.insert(null, "test");
                openTable.insert(null, "test");
                return null;
View Full Code Here

                    SqlJetDb db = null;
                    try {
                        final int n = i++;
                        db = SqlJetDb.open(file, true);
                        synchronized (TransactionTask.class) {
                            db.runWriteTransaction(new ISqlJetTransaction() {
                                public Object run(SqlJetDb db) throws SqlJetException {
                                    return workInTransaction(db, n);
                                }
                            });
                        }
View Full Code Here

TOP

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

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.