Altibase.jdbc.driver.sharding.core

## Class AltibaseShardingConnection

- java.lang.Object
- - Altibase.jdbc.driver.sharding.core.JdbcMethodInvoker
  - - Altibase.jdbc.driver.sharding.core.AltibaseShardingConnection

All Implemented Interfaces:
  java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper

    public class AltibaseShardingConnection
    extends JdbcMethodInvoker
    implements java.sql.Connection

java.sql.Connection 을 구현하며 메타서버와 커넥션을 생성한 후 데이터노드 리스트를 전달받는다.

### Field Summary

Fields
`static byte` `DEFAULT_SHARD_CLIENT`
`static byte` `DEFAULT_SHARD_SESSION_TYPE`

### Fields inherited from interface java.sql.Connection

`TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE`

### Constructor Summary

Constructors
Constructor and Description
`AltibaseShardingConnection(AltibaseProperties aProp)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clearWarnings()`
`void` `close()`
`void` `commit()`
`java.sql.Statement` `createStatement()`
`java.sql.Statement` `createStatement(int aResultSetType, int aResultSetConcurrency)`
`java.sql.Statement` `createStatement(int aResultSetType, int aResultSetConcurrency, int aResultSetHoldability)`
`void` `deregisterFailoverCallback()`
`boolean` `getAutoCommit()`
`java.util.Map<DataNode,java.sql.Connection>` `getCachedConnections()`
`java.lang.String` `getCatalog()`
`int` `getHoldability()`
`java.sql.DatabaseMetaData` `getMetaData()`
`java.sql.Connection` `getNodeConnection(DataNode aNode, boolean aIsToAlternate)` 데이터노드의 Connection을 가져온다.
`AltibaseProperties` `getProps()`
`CmProtocolContextShardConnect` `getShardContextConnect()`
`AltibaseShardingFailover` `getShardFailover()`
`ShardNodeConfig` `getShardNodeConfig()`
`ShardTransactionLevel` `getShardTransactionLevel()`
`int` `getTransactionIsolation()`
`java.util.Map<java.lang.String,java.lang.Class<?>>` `getTypeMap()`
`java.sql.SQLWarning` `getWarnings()`
`boolean` `isClosed()`
`boolean` `isLazyNodeConnect()`
`boolean` `isReadOnly()`
`java.lang.String` `nativeSQL(java.lang.String aSql)`
`java.sql.CallableStatement` `prepareCall(java.lang.String aSql)`
`java.sql.CallableStatement` `prepareCall(java.lang.String aSql, int aResultSetType, int aResultSetConcurrency)`
`java.sql.CallableStatement` `prepareCall(java.lang.String aSql, int aResultSetType, int aResultSetConcurrency, int aResultSetHoldability)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql, int aAutoGeneratedKeys)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql, int[] aColumnIndexes)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql, int aResultSetType, int aResultSetConcurrency)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql, int aResultSetType, int aResultSetConcurrency, int aResultSetHoldability)`
`java.sql.PreparedStatement` `prepareStatement(java.lang.String aSql, java.lang.String[] aColumnNames)`
`void` `registerFailoverCallback(AltibaseFailoverCallback aFailoverCallback, java.lang.Object aAppContext)`
`void` `releaseSavepoint(java.sql.Savepoint aSavepoint)`
`void` `removeNode(DataNode aNode)`
`void` `rollback()`
`void` `rollback(java.sql.Savepoint aSavepoint)`
`void` `setAutoCommit(boolean aAutoCommit)`
`void` `setCatalog(java.lang.String catalog)`
`void` `setChannel(CmChannel aChannel)`
`void` `setClosed(boolean aIsClosed)`
`void` `setHoldability(int aHoldability)`
`void` `setNeedToDisconnect(boolean aNeedToDisconnect)`
`void` `setReadOnly(boolean aReadOnly)`
`java.sql.Savepoint` `setSavepoint()`
`java.sql.Savepoint` `setSavepoint(java.lang.String aName)`
`void` `setShardMetaNumberOfDataNode(long aSMN)` DataNode의 SMN이 클라이언트의 SMN보다 클 경우에는 DataNode의 SMN을 복사한다.
`void` `setShardTransactionLevel(ShardTransactionLevel aShardTransactionLevel)`
`void` `setTransactionIsolation(int aLevel)`
`void` `setTypeMap(java.util.Map aMap)`
`void` `setWarning(java.sql.SQLWarning aWarning)`
`boolean` `shouldUpdateShardMetaNumber()` Meta가 가지고 있는 ShardMetaNumer와 DataNode의 SMN값을 비교하여 ShardMetaNumber가 DataNode SMN보다 작을 경우 true를 리턴한다.
`void` `updateShardMetaNumber()` 메타서버에 getNodeList프로토콜을 다시 요청해 SMN값을 갱신한다.

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

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

### Methods inherited from interface java.sql.Connection

`abort, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, getClientInfo, getClientInfo, getNetworkTimeout, getSchema, isValid, setClientInfo, setClientInfo, setNetworkTimeout, setSchema`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

### Field Detail

#### DEFAULT_SHARD_CLIENT

    public static final byte DEFAULT_SHARD_CLIENT

See Also:
  Constant Field Values

#### DEFAULT_SHARD_SESSION_TYPE

    public static final byte DEFAULT_SHARD_SESSION_TYPE

See Also:
  Constant Field Values

### Constructor Detail

#### AltibaseShardingConnection

    public AltibaseShardingConnection(AltibaseProperties aProp)
                               throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

### Method Detail

#### nativeSQL

    public java.lang.String nativeSQL(java.lang.String aSql)

Specified by:
  `nativeSQL` in interface `java.sql.Connection`

#### setAutoCommit

    public void setAutoCommit(boolean aAutoCommit)
                       throws java.sql.SQLException

Specified by:
  `setAutoCommit` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### getAutoCommit

    public boolean getAutoCommit()

Specified by:
  `getAutoCommit` in interface `java.sql.Connection`

#### commit

    public void commit()
                throws java.sql.SQLException

Specified by:
  `commit` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### rollback

    public void rollback()
                  throws java.sql.SQLException

Specified by:
  `rollback` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### rollback

    public void rollback(java.sql.Savepoint aSavepoint)
                  throws java.sql.SQLException

Specified by:
  `rollback` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### close

    public void close()
               throws java.sql.SQLException

Specified by:
  `close` in interface `java.lang.AutoCloseable`
Specified by:
  `close` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### isClosed

    public boolean isClosed()

Specified by:
  `isClosed` in interface `java.sql.Connection`

#### getMetaData

    public java.sql.DatabaseMetaData getMetaData()
                                          throws java.sql.SQLException

Specified by:
  `getMetaData` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### setReadOnly

    public void setReadOnly(boolean aReadOnly)

Specified by:
  `setReadOnly` in interface `java.sql.Connection`

#### isReadOnly

    public boolean isReadOnly()

Specified by:
  `isReadOnly` in interface `java.sql.Connection`

#### setCatalog

    public void setCatalog(java.lang.String catalog)

Specified by:
  `setCatalog` in interface `java.sql.Connection`

#### getCatalog

    public java.lang.String getCatalog()

Specified by:
  `getCatalog` in interface `java.sql.Connection`

#### setTransactionIsolation

    public void setTransactionIsolation(int aLevel)
                                 throws java.sql.SQLException

Specified by:
  `setTransactionIsolation` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### getTransactionIsolation

    public int getTransactionIsolation()

Specified by:
  `getTransactionIsolation` in interface `java.sql.Connection`

#### getWarnings

    public java.sql.SQLWarning getWarnings()

Specified by:
  `getWarnings` in interface `java.sql.Connection`

#### clearWarnings

    public void clearWarnings()
                       throws java.sql.SQLException

Specified by:
  `clearWarnings` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### createStatement

    public java.sql.Statement createStatement()
                                       throws java.sql.SQLException

Specified by:
  `createStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### createStatement

    public java.sql.Statement createStatement(int aResultSetType,
                                              int aResultSetConcurrency)
                                       throws java.sql.SQLException

Specified by:
  `createStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### createStatement

    public java.sql.Statement createStatement(int aResultSetType,
                                              int aResultSetConcurrency,
                                              int aResultSetHoldability)
                                       throws java.sql.SQLException

Specified by:
  `createStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql,
                                                       int aResultSetType,
                                                       int aResultSetConcurrency)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql,
                                                       int aResultSetType,
                                                       int aResultSetConcurrency,
                                                       int aResultSetHoldability)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql,
                                                       int aAutoGeneratedKeys)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql,
                                                       int[] aColumnIndexes)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String aSql,
                                                       java.lang.String[] aColumnNames)
                                                throws java.sql.SQLException

Specified by:
  `prepareStatement` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareCall

    public java.sql.CallableStatement prepareCall(java.lang.String aSql)
                                           throws java.sql.SQLException

Specified by:
  `prepareCall` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareCall

    public java.sql.CallableStatement prepareCall(java.lang.String aSql,
                                                  int aResultSetType,
                                                  int aResultSetConcurrency)
                                           throws java.sql.SQLException

Specified by:
  `prepareCall` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### prepareCall

    public java.sql.CallableStatement prepareCall(java.lang.String aSql,
                                                  int aResultSetType,
                                                  int aResultSetConcurrency,
                                                  int aResultSetHoldability)
                                           throws java.sql.SQLException

Specified by:
  `prepareCall` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### getTypeMap

    public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
                                                                  throws java.sql.SQLException

Specified by:
  `getTypeMap` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### setTypeMap

    public void setTypeMap(java.util.Map aMap)
                    throws java.sql.SQLException

Specified by:
  `setTypeMap` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### setHoldability

    public void setHoldability(int aHoldability)

Specified by:
  `setHoldability` in interface `java.sql.Connection`

#### getHoldability

    public int getHoldability()

Specified by:
  `getHoldability` in interface `java.sql.Connection`

#### setSavepoint

    public java.sql.Savepoint setSavepoint()
                                    throws java.sql.SQLException

Specified by:
  `setSavepoint` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### setSavepoint

    public java.sql.Savepoint setSavepoint(java.lang.String aName)
                                    throws java.sql.SQLException

Specified by:
  `setSavepoint` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### releaseSavepoint

    public void releaseSavepoint(java.sql.Savepoint aSavepoint)
                          throws java.sql.SQLException

Specified by:
  `releaseSavepoint` in interface `java.sql.Connection`
Throws:
  `java.sql.SQLException`

#### setChannel

    public void setChannel(CmChannel aChannel)

#### getNodeConnection

    public java.sql.Connection getNodeConnection(DataNode aNode,
                                                 boolean aIsToAlternate)
                                          throws java.sql.SQLException

데이터노드의 Connection을 가져온다. 만약 해당하는 노드의 Connection이 캐시에 존재하면 바로 리턴하고
아닌경우 새로 생성한다.

Parameters:
  `aNode` - 데이터노드 객체
  `aIsToAlternate` - alternate로의 접속 여부
Returns:
  데이터노드 커넥션
Throws:
  `java.sql.SQLException` - 커넥션 생성 도중 에러가 발생한 경우

#### getCachedConnections

    public java.util.Map<DataNode,java.sql.Connection> getCachedConnections()

#### getProps

    public AltibaseProperties getProps()

#### getShardNodeConfig

    public ShardNodeConfig getShardNodeConfig()

#### setShardMetaNumberOfDataNode

    public void setShardMetaNumberOfDataNode(long aSMN)

DataNode의 SMN이 클라이언트의 SMN보다 클 경우에는 DataNode의 SMN을 복사한다.

Parameters:
  `aSMN` - error message에서 파싱한 SMN값

#### setNeedToDisconnect

    public void setNeedToDisconnect(boolean aNeedToDisconnect)

#### isLazyNodeConnect

    public boolean isLazyNodeConnect()

#### shouldUpdateShardMetaNumber

    public boolean shouldUpdateShardMetaNumber()

Meta가 가지고 있는 ShardMetaNumer와 DataNode의 SMN값을 비교하여 ShardMetaNumber가 DataNode SMN보다 작을 경우 true를 리턴한다.

Returns:
  DataNode SMN이 더 최신인지 여부

#### updateShardMetaNumber

    public void updateShardMetaNumber()
                               throws java.sql.SQLException

메타서버에 getNodeList프로토콜을 다시 요청해 SMN값을 갱신한다.

Throws:
  `java.sql.SQLException`

#### removeNode

    public void removeNode(DataNode aNode)

#### getShardContextConnect

    public CmProtocolContextShardConnect getShardContextConnect()

#### getShardFailover

    public AltibaseShardingFailover getShardFailover()

#### setWarning

    public void setWarning(java.sql.SQLWarning aWarning)

#### registerFailoverCallback

    public void registerFailoverCallback(AltibaseFailoverCallback aFailoverCallback,
                                         java.lang.Object aAppContext)
                                  throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

#### deregisterFailoverCallback

    public void deregisterFailoverCallback()
                                    throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

#### setClosed

    public void setClosed(boolean aIsClosed)

#### getShardTransactionLevel

    public ShardTransactionLevel getShardTransactionLevel()

#### setShardTransactionLevel

    public void setShardTransactionLevel(ShardTransactionLevel aShardTransactionLevel)