Package org.tmatesoft.sqljet.core.table

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


    }

    @Test
    public void addField4() throws SqlJetException {
        final ISqlJetTableDef alterTable = db.alterTable("alter table t add column b int not null default 0;");
        final ISqlJetTable t = db.getTable("t");
        Assert.assertNotNull(alterTable);
        Assert.assertNotNull(alterTable.getColumn("b"));
        Assert.assertNotNull(table.getDefinition().getColumn("b"));
        Assert.assertNotNull(t);
        Assert.assertNotNull(t.getDefinition().getColumn("b"));
        assertDbOpen();
    }
View Full Code Here


    @Test
    public void renameTable() throws SqlJetException {
        final ISqlJetTableDef alterTable = db.alterTable("alter table t rename to t1;");
        Assert.assertNotNull(alterTable);
        Assert.assertTrue("t1".equals(alterTable.getName()));
        final ISqlJetTable t = db.getTable("t1");
        Assert.assertNotNull(t);
        assertDbOpen();
    }
View Full Code Here

    @Test
    public void testIsNull() throws Exception {
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
              ISqlJetTable table = db.getTable("beans");
              table.insertOr(SqlJetConflictAction.REPLACE, null, "SOME MESSAGE");
              return true;
            }
          }, SqlJetTransactionMode.WRITE);

         db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
              ISqlJetTable table = db.getTable("beans");
              ISqlJetCursor cur = table.lookup(table.getPrimaryKeyIndexName(),1);
              if (!cur.eof()) {
                long v = cur.getInteger(0);
                Assert.assertEquals(1, v);
                boolean isNull = cur.isNull(0); // -> returns true
                Assert.assertFalse(isNull);
View Full Code Here

        dbFile.delete();
    }

    @Test
    public void testLoadManyData() throws Exception {
        ISqlJetTable table = db.getTable("places");
        try {
            db.beginTransaction(SqlJetTransactionMode.WRITE);
            File errTxt = new File("src/test/data/issues/133/err.txt");
            FileInputStream input = new FileInputStream(errTxt);
            BufferedReader reader = new BufferedReader(new InputStreamReader(input, "utf-8"));

            int counter = 0;
            while (true) {
                String line = reader.readLine();
                if (line == null) {
                    break;
                }
                String[] data = line.split("\t");

                table.insert(null, Long.valueOf(data[1]), Long.valueOf(data[2]), Long.valueOf(data[3]), data[4],
                        Long.valueOf(data[5]), Long.valueOf(data[6]), Long.valueOf(data[7]));

                counter++;
                if (counter % 1000 == 0) {
                    db.commit();
View Full Code Here

        String sql1 = "CREATE TABLE [dimensions_2] ( [id] int NOT NULL, [Dimension_Name] varchar(30) NULL,"
                + "[Type_ID] int NOT NULL ) ";
        db.createTable(sql1);
        db.commit();
        Assert.assertTrue(true);
        final ISqlJetTable table = db.getTable("dimensions_2");
        Assert.assertNotNull(table);
    }
View Full Code Here

        String sql1 = "CREATE TABLE \"name with whitespace\" ( \"id\" int NOT NULL, \"Dimension_Name\" varchar(30) NULL,"
                + "\"Type_ID\" int NOT NULL ) ";
        db.createTable(sql1);
        db.commit();
        Assert.assertTrue(true);
        final ISqlJetTable table = db.getTable("name with whitespace");
        Assert.assertNotNull(table);
    }
View Full Code Here

                + "\"DRILLDOWN\" VARCHAR2(100),"
                + "CONSTRAINT \"PK_FUSION_MAP_COUNTRIES\" PRIMARY KEY (\"ID\", \"MAP\")" + ")";
        db.createTable(sql1);
        db.commit();
        Assert.assertTrue(true);
        final ISqlJetTable table = db.getTable("FUSION_MAP_COUNTRIES");
        Assert.assertNotNull(table);
    }
View Full Code Here

    @Test
    public void dollarInName() throws Exception {
        final String sql = "create table my$table(a$ integer primary key, b$ integer)";
        final ISqlJetTableDef def = db.createTable(sql);
        Assert.assertNotNull(def);
        final ISqlJetTable t = db.getTable("my$table");
        Assert.assertNotNull(t);
    }
View Full Code Here

        db.createTable(sql1);
        db.commit();
        db.close();
        db.open();
        Assert.assertTrue(true);
        final ISqlJetTable table = db.getTable("name with whitespace");
        Assert.assertNotNull(table);
    }
View Full Code Here

        db.createIndex(sql2);
        db.commit();
        db.close();
        db.open();
        Assert.assertTrue(true);
        final ISqlJetTable table = db.getTable("name with whitespace");
        Assert.assertNotNull(table);
        final ISqlJetIndexDef indexDef = table.getIndexDef("name with whitespace 2");
        Assert.assertNotNull(indexDef);
    }
View Full Code Here

TOP

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

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.