Search in sources :

Example 6 with TableName

use of org.infinispan.persistence.jdbc.impl.table.TableName in project infinispan by infinispan.

the class TableManagerTest method testDrop.

@Test(dependsOnMethods = "testExists")
public void testDrop() throws Exception {
    TableName dataTableName = tableManager.getDataTableName();
    TableName metaTableName = tableManager.getMetaTableName();
    assert tableManager.tableExists(connection, dataTableName);
    assert tableManager.tableExists(connection, metaTableName);
    byte[] data = new byte[64];
    new Random().nextBytes(data);
    PreparedStatement ps = null;
    try {
        ps = connection.prepareStatement("INSERT INTO " + tableManager.getDataTableName() + "(ID_COLUMN, DATA_COLUMN, TIMESTAMP_COLUMN, SEGMENT_COLUMN) values(?, ?, ?, ?)");
        ps.setString(1, System.currentTimeMillis() + "");
        ps.setBytes(2, data);
        ps.setLong(3, System.currentTimeMillis());
        ps.setLong(4, 1);
        assert 1 == ps.executeUpdate();
    } finally {
        org.infinispan.persistence.jdbc.common.JdbcUtil.safeClose(ps);
    }
    tableManager.dropTables(connection);
    assert !tableManager.tableExists(connection, dataTableName);
    assert !tableManager.tableExists(connection, metaTableName);
}
Also used : TableName(org.infinispan.persistence.jdbc.impl.table.TableName) Random(java.util.Random) PreparedStatement(java.sql.PreparedStatement) Test(org.testng.annotations.Test) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest)

Example 7 with TableName

use of org.infinispan.persistence.jdbc.impl.table.TableName in project infinispan by infinispan.

the class TableManagerTest method testTableQuoting.

public void testTableQuoting() throws Exception {
    TableName dataTableName = tableManager.getDataTableName();
    tableManager.dropDataTable(connection);
    assert !existsTable(connection, dataTableName);
    tableManager.createDataTable(connection);
    assert existsTable(connection, tableManager.getDataTableName());
}
Also used : TableName(org.infinispan.persistence.jdbc.impl.table.TableName)

Aggregations

TableName (org.infinispan.persistence.jdbc.impl.table.TableName)7 ConnectionFactory (org.infinispan.persistence.jdbc.common.connectionfactory.ConnectionFactory)2 Test (org.testng.annotations.Test)2 PreparedStatement (java.sql.PreparedStatement)1 Random (java.util.Random)1 JdbcStringBasedStore (org.infinispan.persistence.jdbc.stringbased.JdbcStringBasedStore)1 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)1