Package com.taosdata.jdbc

## Class TSDBJNIConnector

- java.lang.Object
- - com.taosdata.jdbc.TSDBJNIConnector

    public class TSDBJNIConnector
    extends Object

### Constructor Summary

Constructors
`TSDBJNIConnector()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `closeConnection()` Execute close operation from C to release connection pointer by JNI
`boolean` `connect​(String host, int port, String dbName, String user, String password)` Get connection pointer
`long` `consume​(long subscription)` Consume a subscribed table
`long` `executeQuery​(String sql)` Execute DML/DDL operation
`int` `fetchRow​(long resultSet, TSDBResultSetRowData rowData)` Get one row data
`int` `freeResultSet()` Close the open result set which is associated to the current connection.
`int` `freeResultSet​(long result)` Free resultset operation from C to release resultset pointer by JNI
`int` `getAffectedRows​(long pSql)` Get affected rows count
`int` `getErrCode​(Long pSql)` Get recent error code by connection
`String` `getErrMsg​(Long pSql)` Get recent error message by connection
`long` `getResultSet()` Get resultset pointer Each connection should have a single open result set at a time
`int` `getSchemaMetaData​(long resultSet, List<ColumnMetaData> columnMetaData)` Get schema metadata
`static String` `getTsCharset()`
`static void` `init​(String configDir, String locale, String charset, String timezone)` Initialize static variables in JNI to optimize performance
`static void` `initImp​(String configDir)`
`boolean` `isClosed()` Whether the connection is closed
`boolean` `isResultsetClosed()` Returns the status of last result set in current connection
`static int` `setOptions​(int optionIndex, String optionValue)`
`long` `subscribe​(String topic, String sql, boolean restart, int period)` Subscribe to a table in TSDB
`long` `subscribeImp​(long connection, boolean restart, String topic, String sql, int period)`
`void` `unsubscribe​(long subscription, boolean isKeep)` Unsubscribe a table
`boolean` `validateCreateTableSql​(String sql)` Validate if a create table sql statement is correct without actually creating that table

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TSDBJNIConnector

    public TSDBJNIConnector()

### Method Detail

#### isClosed

    public boolean isClosed()

Whether the connection is closed

#### isResultsetClosed

    public boolean isResultsetClosed()

Returns the status of last result set in current connection

#### init

    public static void init​(String configDir,
                            String locale,
                            String charset,
                            String timezone)
                     throws SQLWarning

Initialize static variables in JNI to optimize performance

Throws:
  `SQLWarning`

#### initImp

    public static void initImp​(String configDir)

#### setOptions

    public static int setOptions​(int optionIndex,
                                 String optionValue)

#### getTsCharset

    public static String getTsCharset()

#### connect

    public boolean connect​(String host,
                           int port,
                           String dbName,
                           String user,
                           String password)
                    throws SQLException

Get connection pointer

Throws:
  `SQLException`

#### executeQuery

    public long executeQuery​(String sql)
                      throws SQLException

Execute DML/DDL operation

Throws:
  `SQLException`

#### getErrCode

    public int getErrCode​(Long pSql)

Get recent error code by connection

#### getErrMsg

    public String getErrMsg​(Long pSql)

Get recent error message by connection

#### getResultSet

    public long getResultSet()

Get resultset pointer Each connection should have a single open result set at a time

#### freeResultSet

    public int freeResultSet​(long result)

Free resultset operation from C to release resultset pointer by JNI

#### freeResultSet

    public int freeResultSet()

Close the open result set which is associated to the current connection. If the result set is already closed, return 0 for success.

#### getAffectedRows

    public int getAffectedRows​(long pSql)

Get affected rows count

#### getSchemaMetaData

    public int getSchemaMetaData​(long resultSet,
                                 List<ColumnMetaData> columnMetaData)

Get schema metadata

#### fetchRow

    public int fetchRow​(long resultSet,
                        TSDBResultSetRowData rowData)

Get one row data

#### closeConnection

    public void closeConnection()
                         throws SQLException

Execute close operation from C to release connection pointer by JNI

Throws:
  `SQLException`

#### subscribe

    public long subscribe​(String topic,
                          String sql,
                          boolean restart,
                          int period)

Subscribe to a table in TSDB

#### subscribeImp

    public long subscribeImp​(long connection,
                             boolean restart,
                             String topic,
                             String sql,
                             int period)

#### consume

    public long consume​(long subscription)

Consume a subscribed table

#### unsubscribe

    public void unsubscribe​(long subscription,
                            boolean isKeep)

Unsubscribe a table

Parameters:
  `subscription` -

#### validateCreateTableSql

    public boolean validateCreateTableSql​(String sql)

Validate if a create table sql statement is correct without actually creating that table