Java Code Examples for com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection

The following examples show how to use com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: canal-1.1.3   Source File: TableMetaCacheTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSimple() throws IOException {
    MysqlConnection connection = new MysqlConnection(new InetSocketAddress("127.0.0.1", 3306), "root", "hello");
    try {
        connection.connect();
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }

    List<ResultSetPacket> packets = connection.queryMulti("show create table test.ljh_test");
    String createDDL = null;
    if (packets.get(0).getFieldValues().size() > 0) {
        createDDL = packets.get(0).getFieldValues().get(1);
    }

    System.out.println(createDDL);

    // TableMetaCache cache = new TableMetaCache(connection);
    // TableMeta meta = cache.getTableMeta("otter1", "otter_stability1");
    // Assert.assertNotNull(meta);
    // for (FieldMeta field : meta.getFields()) {
    // System.out.println("filed :" + field.getColumnName() + " , isKey : "
    // + field.isKey() + " , isNull : "
    // + field.isNullable());
    // }
}
 
Example 2
Source Project: canal   Source File: TableMetaCacheTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSimple() throws IOException {
    MysqlConnection connection = new MysqlConnection(new InetSocketAddress("127.0.0.1", 3306), "root", "hello");
    try {
        connection.connect();
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }

    List<ResultSetPacket> packets = connection.queryMulti("show create table test.ljh_test");
    String createDDL = null;
    if (packets.get(0).getFieldValues().size() > 0) {
        createDDL = packets.get(0).getFieldValues().get(1);
    }

    System.out.println(createDDL);

    // TableMetaCache cache = new TableMetaCache(connection);
    // TableMeta meta = cache.getTableMeta("otter1", "otter_stability1");
    // Assert.assertNotNull(meta);
    // for (FieldMeta field : meta.getFields()) {
    // System.out.println("filed :" + field.getColumnName() + " , isKey : "
    // + field.isKey() + " , isNull : "
    // + field.isNullable());
    // }
}
 
Example 3
Source Project: canal-1.1.3   Source File: DatabaseTableMeta.java    License: Apache License 2.0 4 votes vote down vote up
public void setConnection(MysqlConnection connection) {
    this.connection = connection;
}
 
Example 4
Source Project: canal-1.1.3   Source File: DatabaseTableMeta.java    License: Apache License 2.0 4 votes vote down vote up
public MysqlConnection getConnection() {
    return connection;
}
 
Example 5
Source Project: canal   Source File: DatabaseTableMeta.java    License: Apache License 2.0 4 votes vote down vote up
public void setConnection(MysqlConnection connection) {
    this.connection = connection;
}
 
Example 6
Source Project: canal   Source File: DatabaseTableMeta.java    License: Apache License 2.0 4 votes vote down vote up
public MysqlConnection getConnection() {
    return connection;
}