Search in sources :

Example 1 with MysqlConnection

use of com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection in project canal by alibaba.

the class TableMetaCacheTest method testSimple.

@Test
public void testSimple() {
    MysqlConnection connection = new MysqlConnection(new InetSocketAddress("127.0.0.1", 3306), "xxxxx", "xxxxx");
    try {
        connection.connect();
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
    TableMetaCache cache = new TableMetaCache(connection);
    TableMeta meta = cache.getTableMeta("otter1", "otter_stability1");
    Assert.assertNotNull(meta);
    for (FieldMeta field : meta.getFileds()) {
        System.out.println("filed :" + field.getColumnName() + " , isKey : " + field.isKey() + " , isNull : " + field.isNullable());
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) FieldMeta(com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta) MysqlConnection(com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection) IOException(java.io.IOException) TableMetaCache(com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache) Test(org.junit.Test)

Aggregations

FieldMeta (com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta)1 MysqlConnection (com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection)1 TableMetaCache (com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Test (org.junit.Test)1