├── .java.policy ├── .secignore ├── LICENSE ├── README.md ├── aci.yml ├── formatter.xml ├── oceanbase-jdbc.release ├── pom.xml └── src ├── main ├── java │ └── com │ │ ├── alipay │ │ └── oceanbase │ │ │ ├── jdbc │ │ │ └── Driver.java │ │ │ └── obproxy │ │ │ └── mysql │ │ │ └── jdbc │ │ │ └── Driver.java │ │ └── oceanbase │ │ └── jdbc │ │ ├── AutoGeneratedKey.java │ │ ├── BasePrepareStatement.java │ │ ├── Blob.java │ │ ├── BlobFromLocator.java │ │ ├── BlobOutputStream.java │ │ ├── CallParameter.java │ │ ├── CallableFunctionStatement.java │ │ ├── CallableParameterMetaData.java │ │ ├── CallableProcedureStatement.java │ │ ├── ClientSidePreparedStatement.java │ │ ├── Clob.java │ │ ├── ConnectionImpl.java │ │ ├── Driver.java │ │ ├── ExceptionInterceptor.java │ │ ├── HostAddress.java │ │ ├── JDBC4CallableStatement.java │ │ ├── JDBC4DatabaseMetaData.java │ │ ├── JDBC4MySQLConnection.java │ │ ├── JDBC4NClob.java │ │ ├── JDBC4PreparedStatement.java │ │ ├── JDBC4ResultSet.java │ │ ├── JDBC4ServerCallableStatement.java │ │ ├── JDBC4ServerPreparedStatement.java │ │ ├── JDBC4UpdatableResultSet.java │ │ ├── Lob.java │ │ ├── LobOutputStream.java │ │ ├── LocalInfileInterceptor.java │ │ ├── MysqlConnection.java │ │ ├── MysqlSavepoint.java │ │ ├── ObArray.java │ │ ├── ObComplexData.java │ │ ├── ObConnection.java │ │ ├── ObPrepareStatement.java │ │ ├── ObResultSet.java │ │ ├── ObStruct.java │ │ ├── OceanBaseCallableParameterMetaData.java │ │ ├── OceanBaseConnection.java │ │ ├── OceanBaseDataSource.java │ │ ├── OceanBaseDatabaseMetaData.java │ │ ├── OceanBaseFunctionStatement.java │ │ ├── OceanBaseOracleDatabaseMetadata.java │ │ ├── OceanBaseParameterMetaData.java │ │ ├── OceanBasePoolDataSource.java │ │ ├── OceanBasePooledConnection.java │ │ ├── OceanBaseProcedureStatement.java │ │ ├── OceanBaseResultSetMetaData.java │ │ ├── OceanBaseSavepoint.java │ │ ├── OceanBaseStatement.java │ │ ├── OceanBaseXaConnection.java │ │ ├── OceanBaseXaResource.java │ │ ├── OceanBaseXid.java │ │ ├── ResultSetImpl.java │ │ ├── ReturnParameter.java │ │ ├── ServerSidePreparedStatement.java │ │ ├── SimpleParameterMetaData.java │ │ ├── TnsDaemon.java │ │ ├── UrlParser.java │ │ ├── authentication │ │ ├── AuthenticationPlugin.java │ │ └── AuthenticationPluginLoader.java │ │ ├── credential │ │ ├── Credential.java │ │ ├── CredentialPlugin.java │ │ ├── CredentialPluginLoader.java │ │ ├── env │ │ │ └── EnvCredentialPlugin.java │ │ └── system │ │ │ └── PropertiesCredentialPlugin.java │ │ ├── extend │ │ └── datatype │ │ │ ├── ArrayImpl.java │ │ │ ├── BINARY_DOUBLE.java │ │ │ ├── BINARY_FLOAT.java │ │ │ ├── ComplexData.java │ │ │ ├── ComplexDataType.java │ │ │ ├── ComplexUtil.java │ │ │ ├── DataTypeUtilities.java │ │ │ ├── Datum.java │ │ │ ├── INTERVALDS.java │ │ │ ├── INTERVALYM.java │ │ │ ├── NUMBER.java │ │ │ ├── NUMBER_FLOAT.java │ │ │ ├── RAW.java │ │ │ ├── RowIdImpl.java │ │ │ ├── RowObCursorData.java │ │ │ ├── StructImpl.java │ │ │ ├── TIMESTAMP.java │ │ │ ├── TIMESTAMPLTZ.java │ │ │ └── TIMESTAMPTZ.java │ │ ├── internal │ │ ├── ColumnType.java │ │ ├── ObOracleDefs.java │ │ ├── com │ │ │ ├── Packet.java │ │ │ ├── read │ │ │ │ ├── Buffer.java │ │ │ │ ├── ErrorPacket.java │ │ │ │ ├── ReadInitialHandShakePacket.java │ │ │ │ ├── dao │ │ │ │ │ ├── CmdInformation.java │ │ │ │ │ ├── CmdInformationBatch.java │ │ │ │ │ ├── CmdInformationMultiple.java │ │ │ │ │ ├── CmdInformationSingle.java │ │ │ │ │ ├── ColumnLabelIndexer.java │ │ │ │ │ └── Results.java │ │ │ │ └── resultset │ │ │ │ │ ├── ColumnDefinition.java │ │ │ │ │ ├── Cursor.java │ │ │ │ │ ├── CursorResultSet.java │ │ │ │ │ ├── RefCursor.java │ │ │ │ │ ├── SelectResultSet.java │ │ │ │ │ ├── SensitiveCursorResultSet.java │ │ │ │ │ ├── UpdatableColumnDefinition.java │ │ │ │ │ ├── UpdatableResultSet.java │ │ │ │ │ └── rowprotocol │ │ │ │ │ ├── BinaryRowProtocol.java │ │ │ │ │ ├── OperationNotSupportedException.java │ │ │ │ │ ├── RowProtocol.java │ │ │ │ │ └── TextRowProtocol.java │ │ │ └── send │ │ │ │ ├── ComQuery.java │ │ │ │ ├── ComStmtExecute.java │ │ │ │ ├── ComStmtFetch.java │ │ │ │ ├── ComStmtPrepare.java │ │ │ │ ├── ComStmtPrepareExecute.java │ │ │ │ ├── SendChangeDbPacket.java │ │ │ │ ├── SendClosePacket.java │ │ │ │ ├── SendHandshakeResponsePacket.java │ │ │ │ ├── SendSslConnectionRequestPacket.java │ │ │ │ ├── authentication │ │ │ │ ├── CachingSha2PasswordPlugin.java │ │ │ │ ├── ClearPasswordPlugin.java │ │ │ │ ├── Ed25519PasswordPlugin.java │ │ │ │ ├── NativePasswordPlugin.java │ │ │ │ ├── OldPasswordPlugin.java │ │ │ │ ├── SendGssApiAuthPacket.java │ │ │ │ ├── SendPamAuthPacket.java │ │ │ │ ├── Sha256PasswordPlugin.java │ │ │ │ ├── ed25519 │ │ │ │ │ ├── README │ │ │ │ │ ├── Utils.java │ │ │ │ │ ├── math │ │ │ │ │ │ ├── Constants.java │ │ │ │ │ │ ├── Curve.java │ │ │ │ │ │ ├── Encoding.java │ │ │ │ │ │ ├── Field.java │ │ │ │ │ │ ├── FieldElement.java │ │ │ │ │ │ ├── GroupElement.java │ │ │ │ │ │ └── ed25519 │ │ │ │ │ │ │ ├── Ed25519FieldElement.java │ │ │ │ │ │ │ ├── Ed25519LittleEndianEncoding.java │ │ │ │ │ │ │ └── ScalarOps.java │ │ │ │ │ └── spec │ │ │ │ │ │ ├── EdDSANamedCurveSpec.java │ │ │ │ │ │ ├── EdDSANamedCurveTable.java │ │ │ │ │ │ └── EdDSAParameterSpec.java │ │ │ │ └── gssapi │ │ │ │ │ ├── GssUtility.java │ │ │ │ │ ├── GssapiAuth.java │ │ │ │ │ ├── StandardGssapiAuthentication.java │ │ │ │ │ └── WindowsNativeSspiAuthentication.java │ │ │ │ └── parameters │ │ │ │ ├── BigDecimalParameter.java │ │ │ │ ├── BooleanParameter.java │ │ │ │ ├── ByteArrayParameter.java │ │ │ │ ├── ByteParameter.java │ │ │ │ ├── DateParameter.java │ │ │ │ ├── DateTimeParameter.java │ │ │ │ ├── DefaultParameter.java │ │ │ │ ├── DoubleParameter.java │ │ │ │ ├── FloatParameter.java │ │ │ │ ├── IntParameter.java │ │ │ │ ├── LocalTimeParameter.java │ │ │ │ ├── LongDataParameterHolder.java │ │ │ │ ├── LongParameter.java │ │ │ │ ├── NullParameter.java │ │ │ │ ├── OBArrayParameter.java │ │ │ │ ├── OBBINARY_DOUBLEParameter.java │ │ │ │ ├── OBBINARY_FLOATParameter.java │ │ │ │ ├── OBByteArrayParameter.java │ │ │ │ ├── OBEmptyLobParameter.java │ │ │ │ ├── OBINTERVALDSParameter.java │ │ │ │ ├── OBINTERVALYMParameter.java │ │ │ │ ├── OBNStringParameter.java │ │ │ │ ├── OBNUMBERParameter.java │ │ │ │ ├── OBNUMBER_FLOATParameter.java │ │ │ │ ├── OBReaderParameter.java │ │ │ │ ├── OBSerializableParameter.java │ │ │ │ ├── OBStreamParameter.java │ │ │ │ ├── OBStringParameter.java │ │ │ │ ├── OBStructParameter.java │ │ │ │ ├── OBTIMESTAMPLTZParameter.java │ │ │ │ ├── OBTIMESTAMPParameter.java │ │ │ │ ├── OBTIMESTAMPTZParameter.java │ │ │ │ ├── OBVarcharParameter.java │ │ │ │ ├── OffsetTimeParameter.java │ │ │ │ ├── ParameterHolder.java │ │ │ │ ├── ReaderParameter.java │ │ │ │ ├── SerializableParameter.java │ │ │ │ ├── ShortParameter.java │ │ │ │ ├── StreamParameter.java │ │ │ │ ├── StringParameter.java │ │ │ │ ├── TimeParameter.java │ │ │ │ ├── TimestampParameter.java │ │ │ │ └── ZonedDateTimeParameter.java │ │ ├── failover │ │ │ ├── AbstractMastersListener.java │ │ │ ├── AbstractMastersSlavesListener.java │ │ │ ├── BlackList │ │ │ │ ├── BlackListConfig.java │ │ │ │ ├── append │ │ │ │ │ ├── AppendStrategy.java │ │ │ │ │ ├── NormalAppend.java │ │ │ │ │ └── RetryDuration.java │ │ │ │ └── recover │ │ │ │ │ ├── RemoveStrategy.java │ │ │ │ │ └── TimeoutRecover.java │ │ │ ├── FailoverProxy.java │ │ │ ├── HandleErrorResult.java │ │ │ ├── Listener.java │ │ │ ├── LoadBalanceStrategy │ │ │ │ ├── BalanceStrategy.java │ │ │ │ ├── GroupBalanceStrategy.java │ │ │ │ ├── GroupRotationStrategy.java │ │ │ │ ├── RandomStrategy.java │ │ │ │ ├── RotationStrategy.java │ │ │ │ └── ServerAffinityStrategy.java │ │ │ ├── impl │ │ │ │ ├── AuroraListener.java │ │ │ │ ├── LoadBalanceAddressList.java │ │ │ │ ├── LoadBalanceDriver.java │ │ │ │ ├── LoadBalanceHostAddress.java │ │ │ │ ├── LoadBalanceInfo.java │ │ │ │ ├── MastersFailoverListener.java │ │ │ │ ├── MastersSlavesListener.java │ │ │ │ └── checkers │ │ │ │ │ ├── BalanceStrategyChecker.java │ │ │ │ │ ├── BlackListStrategyAppendChecker.java │ │ │ │ │ ├── BlackListStrategyRemoveChecker.java │ │ │ │ │ ├── ConfigChecker.java │ │ │ │ │ └── GroupStrategyConfigChecker.java │ │ │ ├── thread │ │ │ │ ├── ConnectionValidator.java │ │ │ │ ├── FailoverLoop.java │ │ │ │ └── TerminableRunnable.java │ │ │ ├── tools │ │ │ │ └── SearchFilter.java │ │ │ └── utils │ │ │ │ ├── ConfigParser.java │ │ │ │ ├── Consts.java │ │ │ │ └── HostStateInfo.java │ │ ├── io │ │ │ ├── LruTraceCache.java │ │ │ ├── TraceObject.java │ │ │ ├── input │ │ │ │ ├── AbstractPacketInputStream.java │ │ │ │ ├── DecompressPacketInputStream.java │ │ │ │ ├── Ob20PacketInputStream.java │ │ │ │ ├── PacketInputStream.java │ │ │ │ ├── ReadAheadBufferedStream.java │ │ │ │ └── StandardPacketInputStream.java │ │ │ ├── output │ │ │ │ ├── AbstractPacketOutputStream.java │ │ │ │ ├── CompressPacketOutputStream.java │ │ │ │ ├── Ob20PacketOutputStream.java │ │ │ │ ├── PacketOutputStream.java │ │ │ │ └── StandardPacketOutputStream.java │ │ │ └── socket │ │ │ │ ├── NamedPipeSocket.java │ │ │ │ ├── OBProxyVCSocket.java │ │ │ │ ├── SharedMemorySocket.java │ │ │ │ ├── SocketHandlerFunction.java │ │ │ │ ├── SocketUtility.java │ │ │ │ └── UnixDomainSocket.java │ │ ├── logging │ │ │ ├── Logger.java │ │ │ ├── LoggerFactory.java │ │ │ ├── NoLogger.java │ │ │ ├── ProtocolLoggingProxy.java │ │ │ └── Slf4JLogger.java │ │ ├── osgi │ │ │ ├── OceanBaseActivator.java │ │ │ └── OceanBaseDataSourceFactory.java │ │ ├── protocol │ │ │ ├── AbstractConnectProtocol.java │ │ │ ├── AbstractMultiSend.java │ │ │ ├── AbstractQueryProtocol.java │ │ │ ├── AsyncMultiRead.java │ │ │ ├── AsyncMultiReadResult.java │ │ │ ├── AuroraProtocol.java │ │ │ ├── MasterProtocol.java │ │ │ ├── MastersSlavesProtocol.java │ │ │ ├── OceanBaseCapabilityFlag.java │ │ │ ├── Protocol.java │ │ │ ├── TimeTrace.java │ │ │ ├── flt │ │ │ │ ├── FullLinkTrace.java │ │ │ │ ├── ObObj.java │ │ │ │ ├── OceanBaseProtocolV20.java │ │ │ │ └── OceanBaseSerialize.java │ │ │ └── tls │ │ │ │ ├── DefaultTlsSocketPlugin.java │ │ │ │ ├── HostnameVerifierImpl.java │ │ │ │ ├── OceanBaseX509KeyManager.java │ │ │ │ └── OceanBaseX509TrustManager.java │ │ └── util │ │ │ ├── BulkStatus.java │ │ │ ├── CallableStatementCache.java │ │ │ ├── ConnectionState.java │ │ │ ├── DeRegister.java │ │ │ ├── HttpClient.java │ │ │ ├── JsonParser.java │ │ │ ├── LRUCache.java │ │ │ ├── LogQueryTool.java │ │ │ ├── OptionUtils.java │ │ │ ├── ParsedCallParameters.java │ │ │ ├── ResourceStatus.java │ │ │ ├── ServerPrepareStatementCache.java │ │ │ ├── SqlStates.java │ │ │ ├── StringCacheUtil.java │ │ │ ├── StringUtils.java │ │ │ ├── Utils.java │ │ │ ├── constant │ │ │ ├── ColumnFlags.java │ │ │ ├── HaMode.java │ │ │ ├── ParameterConstant.java │ │ │ ├── ServerStatus.java │ │ │ ├── StateChange.java │ │ │ └── Version.java │ │ │ ├── dao │ │ │ ├── CallableStatementCacheKey.java │ │ │ ├── ClientPrepareResult.java │ │ │ ├── CloneableCallableStatement.java │ │ │ ├── Identifier.java │ │ │ ├── PrepareResult.java │ │ │ ├── ReconnectDuringTransactionException.java │ │ │ └── ServerPrepareResult.java │ │ │ ├── exceptions │ │ │ ├── ExceptionFactory.java │ │ │ ├── MaxAllowedPacketException.java │ │ │ ├── OceanBaseDataTruncation.java │ │ │ └── OceanBaseSqlException.java │ │ │ ├── pid │ │ │ ├── JnaPidFactory.java │ │ │ └── PidFactory.java │ │ │ ├── pool │ │ │ ├── GlobalStateInfo.java │ │ │ ├── Pool.java │ │ │ ├── PoolMBean.java │ │ │ └── Pools.java │ │ │ └── scheduler │ │ │ ├── DynamicSizedSchedulerImpl.java │ │ │ ├── DynamicSizedSchedulerInterface.java │ │ │ ├── FixedSizedSchedulerImpl.java │ │ │ ├── OceanBaseThreadFactory.java │ │ │ └── SchedulerServiceProviderHolder.java │ │ ├── jdbc2 │ │ └── optional │ │ │ ├── JDBC4MysqlXAConnection.java │ │ │ ├── MysqlXAConnection.java │ │ │ ├── MysqlXAResource.java │ │ │ └── MysqlXid.java │ │ ├── tls │ │ ├── TlsSocketPlugin.java │ │ └── TlsSocketPluginLoader.java │ │ └── util │ │ ├── ConfigurableSocketFactory.java │ │ ├── DefaultOptions.java │ │ ├── DefaultSQLs.java │ │ ├── OceanBaseCRC16.java │ │ ├── OceanBaseCRC32C.java │ │ └── Options.java └── resources │ ├── META-INF │ ├── MANIFEST.MF │ └── services │ │ ├── com.oceanbase.jdbc.authentication.AuthenticationPlugin │ │ ├── com.oceanbase.jdbc.credential.CredentialPlugin │ │ ├── com.oceanbase.jdbc.tls.TlsSocketPlugin │ │ └── java.sql.Driver │ └── oceanbase.properties └── test ├── java └── com │ └── oceanbase │ └── jdbc │ ├── AllowMultiQueriesTest.java │ ├── AsSqlTest.java │ ├── AsSqlTestOracle.java │ ├── AttributeTest.java │ ├── AuroraListenerTest.java │ ├── AutoReconnectTest.java │ ├── BaseOracleTest.java │ ├── BaseTest.java │ ├── BasicBatchTest.java │ ├── BasicFailover.java │ ├── Benchmark │ └── ApiBenchmark.java │ ├── BigQueryTest.java │ ├── BlobOracleTest.java │ ├── BlobTest.java │ ├── BooleanTest.java │ ├── BufferTest.java │ ├── Bugfix.java │ ├── ByteTest.java │ ├── CallStatementOracleTest.java │ ├── CallStatementTest.java │ ├── CancelTest.java │ ├── CatalogTest.java │ ├── CharsetOracleTest.java │ ├── CharsetTest.java │ ├── CheckDataTest.java │ ├── CheckSumForGB2321Test.java │ ├── ChecksumOracleTest.java │ ├── ClientPreparedStatementOracleTest.java │ ├── ClientPreparedStatementParsingOracleTest.java │ ├── ClientPreparedStatementParsingTest.java │ ├── ClientPreparedStatementTest.java │ ├── ClobOracleTest.java │ ├── ClobTest.java │ ├── CollationTest.java │ ├── ComMultiPrepareStatementTest.java │ ├── ComplexOracleTest.java │ ├── ComplexScenarioOracleTestCases.java │ ├── ComplexScenarioTestCases.java │ ├── ConnectionOracleTest.java │ ├── ConnectionTest.java │ ├── CredentialPluginTest.java │ ├── CursorFetchOracleTest.java │ ├── CursorFetchTest.java │ ├── DataNTypeTest.java │ ├── DataNtypeOracleTest.java │ ├── DataSourcePoolTest.java │ ├── DataSourceTest.java │ ├── DataTypeMysqlCompleteTest.java │ ├── DataTypeOracleCompleteTest.java │ ├── DataTypeOracleTest.java │ ├── DataTypeSignedOracleTest.java │ ├── DataTypeSignedTest.java │ ├── DataTypeTest.java │ ├── DataTypeUnsignedOracleTest.java │ ├── DataTypeUnsignedTest.java │ ├── DatabaseMetadataOracleTest.java │ ├── DatabaseMetadataTest.java │ ├── DatatypeCompatibilityTest.java │ ├── DateOracleTest.java │ ├── DateTest.java │ ├── DistributedTransactionTest.java │ ├── DriverOracleTest.java │ ├── DriverTest.java │ ├── ErrorMessageTest.java │ ├── ExecuteBatchOracleTest.java │ ├── ExecuteBatchTest.java │ ├── ExecuteReturnOracleTest.java │ ├── ExecuteReturnTest.java │ ├── FetchSizeTest.java │ ├── GBKTestOracle.java │ ├── GeneratedKeysTest.java │ ├── GeneratedTest.java │ ├── GeometryTest.java │ ├── GiganticLoadDataInfileTest.java │ ├── INTERVALOracleTest.java │ ├── JdbcParserTest.java │ ├── LobLocatorOracleTest.java │ ├── LocalInfileDisableTest.java │ ├── LocalInfileInputStreamTest.java │ ├── LocalInfileInterceptorImpl.java │ ├── LocalTimeTest.java │ ├── MultiTest.java │ ├── MyEventListener.java │ ├── MysqlDataTypeTest.java │ ├── NewFeatureOracleTest.java │ ├── NewFeatureTest.java │ ├── ObProtocolV20OracleTest.java │ ├── ObProtocolV20Test.java │ ├── OceanBaseBlobOracleTest.java │ ├── OceanBaseBlobTest.java │ ├── OceanBaseCompatibilityTest.java │ ├── OceanBasePoolDataSourceTest.java │ ├── OceanBaseXaResourceTest.java │ ├── OceanbaseOracleXATest.java │ ├── OracleBugfix.java │ ├── OracleCmdPreparedExecuteTest.java │ ├── OracleConnectionCompatibilityTest.java │ ├── OracleDataTypeTest.java │ ├── OracleNcharNvarcharTest.java │ ├── OracleReturningIntoTest.java │ ├── OracleTimeZoneTablesImported.java │ ├── ParameterMetaDataOracleTest.java │ ├── ParameterMetaDataTest.java │ ├── ParserTest.java │ ├── PasswordEncodingTest.java │ ├── PooledConnectionTest.java │ ├── PreparedStatementOracleTest.java │ ├── PreparedStatementTest.java │ ├── ProcedureOracleTest.java │ ├── ProcedureTest.java │ ├── RePrepareTest.java │ ├── ReconnectionStateMaxAllowedStatement.java │ ├── RefCursorOracleTest.java │ ├── ResultSetMetaDataOracleTest.java │ ├── ResultSetMetaDataTest.java │ ├── ResultSetOracleTest.java │ ├── ResultSetTest.java │ ├── ResultSetUnsupportedMethodsTest.java │ ├── RowidTest.java │ ├── ScalarFunctionsTest.java │ ├── SerializableClass.java │ ├── ServerPrepareStatementTest.java │ ├── SetSessionTimeZoneOracleTest.java │ ├── Sha256AuthenticationTest.java │ ├── SslTest.java │ ├── StateChangeTest.java │ ├── StatementOracleTest.java │ ├── StatementTest.java │ ├── StoredProcedureOracleBasicTest.java │ ├── StoredProcedureOracleTest.java │ ├── StoredProcedureTest.java │ ├── TimeoutTest.java │ ├── TimezoneDaylightSavingTimeTest.java │ ├── TimezoneExplicitCalendarTest.java │ ├── TransactionTest.java │ ├── TruncateExceptionTest.java │ ├── UnicodeTest.java │ ├── UpdateResultSetOracleTest.java │ ├── UpdateResultSetTest.java │ ├── UrlParserTest.java │ ├── UtilTest.java │ ├── ZonedDateTimeTest.java │ ├── failover │ ├── AllowMasterDownTest.java │ ├── AuroraAutoDiscoveryTest.java │ ├── AuroraFailoverTest.java │ ├── BaseMonoServer.java │ ├── BaseMultiHostTest.java │ ├── BaseReplication.java │ ├── CancelTest.java │ ├── GaleraFailoverTest.java │ ├── LoadBalancTestOracle.java │ ├── LoadBalanceFailoverTest.java │ ├── MonoServerFailoverTest.java │ ├── OldFailoverTest.java │ ├── OracleLoadBalanceFailoverTest.java │ ├── ReplicationFailoverTest.java │ ├── SequentialFailoverTest.java │ ├── TcpProxy.java │ └── TcpProxySocket.java │ └── internal │ ├── com │ └── read │ │ └── resultset │ │ └── ColumnDefinitionTest.java │ ├── protocol │ └── tls │ │ └── HostnameVerifierImplTest.java │ └── util │ ├── DefaultOptionsTest.java │ ├── SchedulerServiceProviderHolderTest.java │ ├── UtilsTest.java │ ├── buffer │ └── BufferTest.java │ └── dao │ └── ClientPrepareResultTest.java └── resources ├── META-INF └── services │ └── com.oceanbase.jdbc.LocalInfileInterceptor ├── VacationRequest.bpmn20.xml ├── conf.properties ├── localInfile.txt ├── logback-test.xml ├── ssl ├── README └── wrong-server.crt └── timezoneTest.sql /.java.policy: -------------------------------------------------------------------------------- 1 | grant { 2 | permission java.sql.SQLPermission "callAbort"; 3 | permission java.sql.SQLPermission "setNetworkTimeout"; 4 | }; 5 | -------------------------------------------------------------------------------- /.secignore: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | # OBFlow Secret Scan Ignore List # 3 | ########################################################## 4 | # Above the segmentation lines there are suspected privacy information # 5 | # Please use the file name as the first line and the igored information # 6 | # should be started with tab. # 7 | # Under the segmentation lines there are the folders which you need to ignore # 8 | ########################################################## 9 | ** 10 | https://gw.alipayobjects.com/zos/bmw-prod/d6c1a0b7-c714-4429-8a33-2b394a5c1bf1.svg 11 | http://oceanbase.com* 12 | https://oceanbase.com* 13 | https://www.oceanbase.com* 14 | https://github.com/* 15 | http://www.gnu.org/licenses/ 16 | http://maven.apache.org/* 17 | http://www.w3.org/2001/XMLSchema-instance 18 | https://en.wikipedia.org/wiki/UTF-16 19 | https://facebook.github.io/watchman/) 20 | www.other.org 21 | www.foo.com 22 | www.other2.org 23 | juliusdavies@gmail.com 24 | email@xxxxx.com.cn 25 | nemproject@gmx.de 26 | www.mariadbtest.org 27 | http://mariadb.org* 28 | https://mariadb.org* 29 | https://mariadb.com* 30 | https://jira.mariadb.org* 31 | https://docs.oracle.com* 32 | https://dev.mysql.com* 33 | https://bugs.mysql.com* 34 | -------------------------------------------------------- 35 | # Should use GLOB wildcard to config and analysis the ignored folder 36 | # The root patch should start with '/' 37 | /src/test/java/com/oceanbase/jdbc/internal/protocol/tls/HostnameVerifierImplTest.java 38 | /src/test/java/com/oceanbase/jdbc/JdbcParserTest.java 39 | /src/test/resources/ssl/wrong-server.crt 40 | -------------------------------------------------------- 41 | # Config the ignored fold to escape the Chinese scan by GLOB wildcard 42 | -------------------------------------------------------- 43 | # Set md5 of pemFile string to filter 44 | # This section must be end up with '--------------------------------------------------------'!!! 45 | **/test/*.pem 46 | -------------------------------------------------------- -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | 7 | # OceanBase Client for Java 8 | OceanBase Client for Java is a JDBC 4.2 compatible driver, used to connect applications developed in Java to OceanBase Database Server. 9 | 10 | # Compatibility 11 | ## Server Compatibility 12 | OceanBase Client for Java is compatible with all OceanBase Database Server versions. 13 | ## Java Compatibility 14 | OceanBase Client for Java is developed based on Java 8, please confirm your Java version. 15 | ## Obtaining the driver 16 | The driver (jar) can be downloaded from maven: 17 | ```script 18 | 19 | com.oceanbase 20 | oceanbase-client 21 | 2.4.14 22 | 23 | ``` 24 | ## Building from source 25 | ```script 26 | mvn clean package -DskipTests 27 | ``` 28 | ## Documentation 29 | For more information about this project, please refer to: 30 | * [About OceanBase](https://www.oceanbase.com/) 31 | * [OceanBase documents](https://www.oceanbase.com/docs) 32 | ## License 33 | 34 | Distributed under the LGPL License. See `LICENSE` for more information. 35 | ## Acknowledgement 36 | 37 | OceanBase Connector/J was ported from MariaDB Connector/J with some OceanBase protocol support and improvement. Thanks to the MariaDB for opening up such a great Database Connector implementation. 38 | -------------------------------------------------------------------------------- /aci.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | 3 | stages: 4 | - 代码扫描 5 | 6 | jobs: 7 | 安全扫描: 8 | stage: 代码扫描 9 | component: stc 10 | inputs: 11 | tenantName: oceanbase # 使用oceanbase规则进行扫描,而不是用主站规则 12 | # checkRule: 13 | # - urgentCount = 0 && highCount = 0 # 卡点规则:高危和严重bug数均为0 14 | # - urgent = 0 && high = 0 15 | 16 | # only: 17 | # triggerType: 18 | # - tagPush -------------------------------------------------------------------------------- /oceanbase-jdbc.release: -------------------------------------------------------------------------------- 1 | # 1. You can edit the content of this file directly , or use tools to help you verify the legality and automatically generate it , please click http=//aliwing.alibaba-inc.com/apprelease/home.htm 2 | # 2. For more about the specifications and conventions of Release files , please click http=//docs.alibaba-inc.com/pages/viewpage.action?pageId=252891532 3 | 4 | code.language=java 5 | 6 | baseline.jdk=jdk-1.8.0_40 7 | 8 | build.tools.maven=maven3.2.5 9 | 10 | build.tools.maven.settings=tao 11 | 12 | build.output=target 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/alipay/oceanbase/jdbc/Driver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.alipay.oceanbase.jdbc; 45 | 46 | import java.sql.*; 47 | 48 | import com.oceanbase.jdbc.internal.util.DeRegister; 49 | 50 | public class Driver extends com.oceanbase.jdbc.Driver { 51 | 52 | static { 53 | try { 54 | DriverManager.registerDriver(new com.oceanbase.jdbc.Driver(), new DeRegister()); 55 | } catch (SQLException e) { 56 | throw new RuntimeException("Could not register driver", e); 57 | } 58 | } 59 | 60 | public Driver() throws SQLException { 61 | // Required for Class.forName().newInstance() 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/com/alipay/oceanbase/obproxy/mysql/jdbc/Driver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.alipay.oceanbase.obproxy.mysql.jdbc; 45 | 46 | import java.sql.DriverManager; 47 | import java.sql.SQLException; 48 | 49 | import com.oceanbase.jdbc.internal.util.DeRegister; 50 | 51 | public class Driver extends com.oceanbase.jdbc.Driver { 52 | 53 | static { 54 | try { 55 | DriverManager.registerDriver(new com.oceanbase.jdbc.Driver(), new DeRegister()); 56 | } catch (SQLException e) { 57 | throw new RuntimeException("Could not register driver", e); 58 | } 59 | } 60 | 61 | public Driver() throws SQLException { 62 | // Required for Class.forName().newInstance() 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ConnectionImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | /** 54 | * Compatible with jdbc1.X interface class, mainly used to add oracle mode interfaces 55 | */ 56 | public interface ConnectionImpl extends JDBC4MySQLConnection { 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ExceptionInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import java.security.cert.Extension; 54 | import java.sql.Connection; 55 | import java.sql.SQLException; 56 | 57 | public interface ExceptionInterceptor extends Extension { 58 | SQLException interceptException(SQLException sqlEx, Connection conn); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/JDBC4MySQLConnection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | public interface JDBC4MySQLConnection extends ObConnection { 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/JDBC4NClob.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import java.sql.NClob; 54 | 55 | public class JDBC4NClob extends Clob implements NClob { 56 | 57 | JDBC4NClob(String charDataInit, ExceptionInterceptor exceptionInterceptor) { 58 | super(charDataInit, exceptionInterceptor); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/LocalInfileInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | public interface LocalInfileInterceptor { 54 | 55 | boolean validate(String fileName); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/MysqlConnection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import java.sql.Connection; 54 | 55 | public interface MysqlConnection extends Connection { 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/MysqlSavepoint.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | public class MysqlSavepoint extends OceanBaseSavepoint { 54 | public MysqlSavepoint(String name) { 55 | super(name); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.Array; 47 | import java.sql.ResultSet; 48 | import java.sql.SQLException; 49 | import java.util.Map; 50 | 51 | public interface ObArray extends ResultSet, Array, ObComplexData { 52 | String getBaseTypeName() throws SQLException; 53 | 54 | int getBaseType() throws SQLException; 55 | 56 | Object getArray() throws SQLException; 57 | 58 | Object getArray(Map> stringClassMap) throws SQLException; 59 | 60 | Object getArray(long index, int count) throws SQLException; 61 | 62 | Object getArray(long index, int count, Map> stringClassMap) 63 | throws SQLException; 64 | 65 | ResultSet getResultSet() throws SQLException; 66 | 67 | ResultSet getResultSet(Map> stringClassMap) throws SQLException; 68 | 69 | ResultSet getResultSet(long index, int count) throws SQLException; 70 | 71 | ResultSet getResultSet(long index, int count, Map> stringClassMap) 72 | throws SQLException; 73 | 74 | void free() throws SQLException; 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObComplexData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import com.oceanbase.jdbc.extend.datatype.ComplexDataType; 47 | 48 | public interface ObComplexData { 49 | ComplexDataType getComplexType(); 50 | 51 | void setComplexType(ComplexDataType complexType); 52 | 53 | Object getAttrData(int attrIndex); 54 | 55 | Object[] getAttrData(); 56 | 57 | void setAttrData(Object[] attrData); 58 | 59 | int getAttrCount(); 60 | 61 | void setAttrCount(int attrCount); 62 | 63 | void addAttrData(int index, Object value); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.SQLException; 47 | 48 | public interface ObConnection extends MysqlConnection { 49 | void setSessionTimeZone(String zoneID) throws SQLException; 50 | 51 | String getSessionTimeZone(); 52 | 53 | void changeUser(String userName, String newPassword) throws SQLException; 54 | 55 | void setRemarksReporting(boolean remarksReporting); 56 | 57 | boolean getRemarksReporting(); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObPrepareStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.PreparedStatement; 47 | import java.sql.Timestamp; 48 | 49 | import com.oceanbase.jdbc.extend.datatype.INTERVALDS; 50 | import com.oceanbase.jdbc.extend.datatype.INTERVALYM; 51 | import com.oceanbase.jdbc.extend.datatype.TIMESTAMPLTZ; 52 | import com.oceanbase.jdbc.extend.datatype.TIMESTAMPTZ; 53 | 54 | public interface ObPrepareStatement extends PreparedStatement { 55 | void setINTERVALDS(int parameterIndex, INTERVALDS intervalds) throws java.sql.SQLException; 56 | 57 | void setINTERVALYM(int parameterIndex, INTERVALYM intervalym) throws java.sql.SQLException; 58 | 59 | void setTIMESTAMP(int parameterIndex, Timestamp timestamp) throws java.sql.SQLException; 60 | 61 | void setTIMESTAMPLTZ(int parameterIndex, TIMESTAMPLTZ timestampltz) 62 | throws java.sql.SQLException; 63 | 64 | void setTIMESTAMPTZ(int parameterIndex, TIMESTAMPTZ timestamptz) throws java.sql.SQLException; 65 | 66 | void setFixedCHAR(int parameterIndex, String parameterStr) throws java.sql.SQLException; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObResultSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.ResultSet; 47 | import java.sql.SQLException; 48 | 49 | import com.oceanbase.jdbc.extend.datatype.*; 50 | 51 | public interface ObResultSet extends ResultSet { 52 | TIMESTAMPTZ getTIMESTAMPTZ(int columnIndex) throws SQLException; 53 | 54 | TIMESTAMPTZ getTIMESTAMPTZ(String columnName) throws SQLException; 55 | 56 | TIMESTAMPLTZ getTIMESTAMPLTZ(int columnIndex) throws SQLException; 57 | 58 | TIMESTAMPLTZ getTIMESTAMPLTZ(String columnName) throws SQLException; 59 | 60 | INTERVALYM getINTERVALYM(int columnIndex) throws SQLException; 61 | 62 | INTERVALYM getINTERVALYM(String columnName) throws SQLException; 63 | 64 | INTERVALDS getINTERVALDS(int columnIndex) throws SQLException; 65 | 66 | INTERVALDS getINTERVALDS(String columnName) throws SQLException; 67 | 68 | NUMBER getNUMBER(int columnIndex) throws SQLException; 69 | 70 | NUMBER getNUMBER(String columnName) throws SQLException; 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ObStruct.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.Struct; 47 | 48 | public interface ObStruct extends ObComplexData, Struct { 49 | // Ensure the interface is consistent Even if it is an empty interface 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/OceanBaseDatabaseMetaData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import java.sql.Connection; 54 | 55 | public class OceanBaseDatabaseMetaData extends JDBC4DatabaseMetaData { 56 | /** 57 | * Constructor. 58 | * 59 | * @param connection connection 60 | * @param urlParser Url parser 61 | */ 62 | public OceanBaseDatabaseMetaData(Connection connection, UrlParser urlParser) { 63 | super(connection, urlParser); 64 | } 65 | } -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/OceanBaseXaConnection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import javax.sql.XAConnection; 54 | import javax.transaction.xa.XAResource; 55 | 56 | public class OceanBaseXaConnection extends OceanBasePooledConnection implements XAConnection { 57 | 58 | public OceanBaseXaConnection(OceanBaseConnection connection) { 59 | super(connection); 60 | } 61 | 62 | @Override 63 | public XAResource getXAResource() { 64 | return new OceanBaseXaResource(getConnection()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/ResultSetImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | public interface ResultSetImpl extends ObResultSet { 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/TnsDaemon.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc; 2 | 3 | import java.io.*; 4 | import java.nio.file.*; 5 | 6 | import com.oceanbase.jdbc.internal.failover.utils.ConfigParser; 7 | 8 | public class TnsDaemon extends Thread { 9 | private static String configFileName = "tnsnames.ob"; 10 | 11 | private void fullFillMap(String tnsPath) throws IOException { 12 | 13 | String filePath = tnsPath + "/" + configFileName; 14 | File file = new File(filePath); 15 | Reader reader = new InputStreamReader(new FileInputStream(file)); 16 | ConfigParser.readLoadBalanceInfosFromTns(reader); 17 | } 18 | 19 | @Override 20 | public void run() { 21 | try { 22 | ConfigParser.ConfigInfo tnsFileInfo = ConfigParser.getTnsFilePath(); 23 | configFileName = tnsFileInfo.name; 24 | fullFillMap(tnsFileInfo.path); 25 | WatchService watchService = FileSystems.getDefault().newWatchService(); 26 | File file1 = new File(tnsFileInfo.path); 27 | file1.toPath().register(watchService, StandardWatchEventKinds.ENTRY_MODIFY); 28 | while (true) { 29 | WatchKey key = watchService.take(); 30 | for (WatchEvent event : key.pollEvents()) { 31 | WatchEvent ev = (WatchEvent) event; 32 | Path filename = ev.context(); 33 | if (filename.toString().equals(configFileName)) { 34 | fullFillMap(tnsFileInfo.path); 35 | } 36 | } 37 | boolean vaild = key.reset(); 38 | if (!vaild) { 39 | break; 40 | } 41 | } 42 | } catch (Throwable throwable) { 43 | throwable.printStackTrace(); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/credential/CredentialPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.credential; 45 | 46 | import java.sql.SQLException; 47 | import java.util.function.Supplier; 48 | 49 | import com.oceanbase.jdbc.HostAddress; 50 | import com.oceanbase.jdbc.util.Options; 51 | 52 | public interface CredentialPlugin extends Supplier { 53 | 54 | String name(); 55 | 56 | String type(); 57 | 58 | default boolean mustUseSsl() { 59 | return false; 60 | } 61 | 62 | default String defaultAuthenticationPluginType() { 63 | return null; 64 | } 65 | 66 | default CredentialPlugin initialize(Options options, String userName, HostAddress hostAddress) 67 | throws SQLException { 68 | return this; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/extend/datatype/RAW.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.extend.datatype; 45 | 46 | import java.sql.SQLException; 47 | 48 | public class RAW extends Datum { 49 | public RAW(byte[] bytes) { 50 | super(bytes); 51 | } 52 | 53 | public RAW(Object val) { 54 | } 55 | 56 | @Override 57 | public boolean isConvertibleTo(Class targetClass) { 58 | return false; 59 | } 60 | 61 | @Override 62 | public Object toJdbc() throws SQLException { 63 | return null; 64 | } 65 | 66 | @Override 67 | public Object makeJdbcArray(int intVal) { 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/extend/datatype/RowIdImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.extend.datatype; 45 | 46 | public class RowIdImpl implements java.sql.RowId { 47 | private String val; 48 | 49 | public RowIdImpl(String value) { 50 | val = value; 51 | } 52 | 53 | @Override 54 | public boolean equals(Object obj) { 55 | if (obj instanceof RowIdImpl) { 56 | if (obj.hashCode() == this.hashCode()) { 57 | return true; 58 | } 59 | } 60 | return false; 61 | } 62 | 63 | @Override 64 | public byte[] getBytes() { 65 | if (val != null) { 66 | return val.getBytes(); 67 | } else { 68 | return new byte[0]; 69 | } 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return val; 75 | } 76 | 77 | @Override 78 | public int hashCode() { 79 | return val != null ? val.hashCode() : 0; 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/extend/datatype/StructImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.extend.datatype; 45 | 46 | import java.sql.SQLException; 47 | import java.util.Map; 48 | 49 | import com.oceanbase.jdbc.ObStruct; 50 | 51 | public class StructImpl extends ComplexData implements ObStruct { 52 | public StructImpl(ComplexDataType type) { 53 | super(type); 54 | } 55 | 56 | @Override 57 | public String getSQLTypeName() throws SQLException { 58 | return this.getComplexType().getTypeName(); 59 | } 60 | 61 | @Override 62 | public Object[] getAttributes() throws SQLException { 63 | return this.getAttrData(); 64 | } 65 | 66 | @Override 67 | public Object[] getAttributes(Map> map) throws SQLException { 68 | return new Object[0]; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/ObOracleDefs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.internal; 45 | 46 | /*** 47 | * Describes the Oracle field type 48 | */ 49 | public class ObOracleDefs { 50 | 51 | public static final int FIELD_JAVA_TYPE_BINARY_DOUBLE = 101; 52 | 53 | public static final int FIELD_JAVA_TYPE_BINARY_FLOAT = 100; 54 | 55 | public static final int FIELD_JAVA_TYPE_NVARCHAR2 = -9; 56 | 57 | public static final int FIELD_JAVA_TYPE_NUMBER = 2; 58 | 59 | public static final int FIELD_JAVA_TYPE_ROWID = -8; 60 | 61 | public static final int FIELD_JAVA_TYPE_NCHAR = -15; 62 | 63 | public static final int FIELD_JAVA_TYPE_CLOB = 2005; 64 | 65 | public static final int FIELD_JAVA_TYPE_INTERVALYM = -103; 66 | public static final int FIELD_JAVA_TYPE_INTERVALDS = -104; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/read/resultset/Cursor.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.com.read.resultset; 2 | 3 | import java.io.IOException; 4 | import java.sql.SQLException; 5 | 6 | import com.oceanbase.jdbc.internal.com.read.dao.Results; 7 | import com.oceanbase.jdbc.internal.protocol.Protocol; 8 | 9 | public abstract class Cursor extends SelectResultSet { 10 | public Cursor(ColumnDefinition[] columnDefinition, Results results, Protocol protocol, 11 | boolean callableResult, boolean eofDeprecated, boolean isPsOutParameter) 12 | throws IOException, 13 | SQLException { 14 | super(columnDefinition, results, protocol, callableResult, eofDeprecated, isPsOutParameter); 15 | } 16 | 17 | protected abstract boolean cursorFetch() throws SQLException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/read/resultset/rowprotocol/OperationNotSupportedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.com.read.resultset.rowprotocol; 52 | 53 | import java.sql.SQLException; 54 | 55 | class OperationNotSupportedException extends SQLException { 56 | 57 | static final long serialVersionUID = 474918612056813430L; 58 | 59 | OperationNotSupportedException() { 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/ComStmtFetch.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.com.send; 52 | 53 | import java.io.IOException; 54 | 55 | import com.oceanbase.jdbc.internal.com.Packet; 56 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream; 57 | 58 | public class ComStmtFetch { 59 | /** 60 | * 61 | * @param pos 62 | * @param fetchSize 63 | * @throws IOException 64 | */ 65 | public static void send(final PacketOutputStream pos, int fetchSize, int statementId) 66 | throws IOException { 67 | pos.startPacket(0); 68 | pos.write(Packet.COM_STMT_FETCH); 69 | pos.writeInt(statementId); 70 | pos.writeInt(fetchSize); 71 | pos.flush(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/SendClosePacket.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.com.send; 52 | 53 | import java.io.IOException; 54 | 55 | import com.oceanbase.jdbc.internal.com.Packet; 56 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream; 57 | 58 | public class SendClosePacket { 59 | 60 | /** 61 | * Send close stream to server. 62 | * 63 | * @param pos write outputStream 64 | */ 65 | public static void send(final PacketOutputStream pos) { 66 | try { 67 | pos.startPacket(0); 68 | pos.write(Packet.COM_QUIT); 69 | pos.flush(); 70 | } catch (IOException ioe) { 71 | // eat 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/authentication/ed25519/README: -------------------------------------------------------------------------------- 1 | This plugin uses public domain ed25519 code by str4d (https://github.com/str4d/ed25519-java). 2 | It is "ref10" java implementation from the SUPERCOP ed25519: 3 | 4 | ============================== 5 | MariaDB changes: 6 | - doesn't register ed25519 to global java providers 7 | - remove unused classes 8 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/authentication/gssapi/GssapiAuth.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.com.send.authentication.gssapi; 52 | 53 | import java.io.IOException; 54 | import java.sql.SQLException; 55 | import java.util.concurrent.atomic.AtomicInteger; 56 | 57 | import com.oceanbase.jdbc.internal.io.input.PacketInputStream; 58 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream; 59 | 60 | public interface GssapiAuth { 61 | 62 | void authenticate(PacketOutputStream writer, PacketInputStream in, AtomicInteger sequence, 63 | String servicePrincipalName, String mechanisms) throws SQLException, 64 | IOException; 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/LongDataParameterHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | 45 | package com.oceanbase.jdbc.internal.com.send.parameters; 46 | 47 | import java.io.IOException; 48 | import java.sql.SQLException; 49 | 50 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream; 51 | import com.oceanbase.jdbc.util.Options; 52 | 53 | public interface LongDataParameterHolder extends ParameterHolder { 54 | public static final int BLOB_STREAM_READ_BUF_SIZE = 8192; // Transplant this one from objdbc 1.x 55 | 56 | public boolean writePieceData(final PacketOutputStream pos, boolean first, Options options) 57 | throws IOException, SQLException; 58 | 59 | public boolean writeLongData(final PacketOutputStream pos, Options options, int statementId, 60 | short paramIndex) throws IOException, SQLException; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/OBEmptyLobParameter.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.com.send.parameters; 2 | 3 | import java.io.IOException; 4 | 5 | import com.oceanbase.jdbc.internal.ColumnType; 6 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream; 7 | 8 | public class OBEmptyLobParameter implements Cloneable, ParameterHolder { 9 | 10 | int lobType = 0; // 0 blob / 1 clob 11 | private byte[] lobLocatorBinary = null; 12 | private static final byte[] EMPTY_CLOB = { 'E', 'M', 'P', 'T', 'Y', '_', 'C', 'L', 'O', 13 | 'B', '(', ')' }; 14 | private static final byte[] EMPTY_BLOB = { 'E', 'M', 'P', 'T', 'Y', '_', 'B', 'L', 'O', 15 | 'B', '(', ')' }; 16 | 17 | public OBEmptyLobParameter(int lobType) { 18 | this.lobType = lobType; 19 | } 20 | 21 | public OBEmptyLobParameter(int lobType, byte[] lobLocatorBinary) { 22 | this.lobType = lobType; 23 | this.lobLocatorBinary = lobLocatorBinary; 24 | } 25 | 26 | @Override 27 | public void writeTo(PacketOutputStream os) throws IOException { 28 | if (this.lobType == 0) { 29 | os.write(EMPTY_BLOB); 30 | } else { 31 | os.write(EMPTY_CLOB); 32 | } 33 | } 34 | 35 | @Override 36 | public void writeBinary(PacketOutputStream pos) throws IOException { 37 | if (lobLocatorBinary != null) { 38 | pos.writeFieldLength(lobLocatorBinary.length); 39 | pos.write(lobLocatorBinary, 0, lobLocatorBinary.length); 40 | } 41 | // writing through reader is equivalent to writing nothing 42 | } 43 | 44 | @Override 45 | public int getApproximateTextProtocolLength() throws IOException { 46 | return 0; 47 | } 48 | 49 | @Override 50 | public boolean isNullData() { 51 | return lobLocatorBinary == null; 52 | } 53 | 54 | /** 55 | * 56 | * @return ColumnType.ORA_CLOB/ORA_CLOB write through locator, and ColumnType.STRING write through reader 57 | */ 58 | @Override 59 | public ColumnType getColumnType() { 60 | return lobLocatorBinary != null ? (lobType == 0 ? ColumnType.ORA_BLOB : ColumnType.ORA_CLOB) 61 | : ColumnType.STRING; 62 | } 63 | 64 | @Override 65 | public boolean isLongData() { 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/OBStringParameter.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.com.send.parameters; 2 | 3 | import com.oceanbase.jdbc.internal.ColumnType; 4 | 5 | public class OBStringParameter extends OBVarcharParameter { 6 | 7 | public OBStringParameter(String str, boolean noBackslashEscapes, String characterEncoding) { 8 | super(str, noBackslashEscapes, characterEncoding); 9 | } 10 | 11 | public ColumnType getColumnType() { 12 | return ColumnType.STRING; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/BlackListConfig.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.BlackList; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.oceanbase.jdbc.internal.failover.BlackList.append.AppendStrategy; 6 | import com.oceanbase.jdbc.internal.failover.BlackList.append.NormalAppend; 7 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.RemoveStrategy; 8 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.TimeoutRecover; 9 | 10 | public class BlackListConfig { 11 | RemoveStrategy removeStrategy; 12 | AppendStrategy appendStrategy; 13 | HashMap removeStrategyConfigs; 14 | HashMap appendStrategyConfigs; 15 | 16 | public BlackListConfig() { 17 | appendStrategyConfigs = new HashMap<>(); 18 | appendStrategyConfigs.put("NAME","NORMAL"); 19 | removeStrategyConfigs = new HashMap<>(); 20 | removeStrategyConfigs.put("NAME","TIMEOUT"); 21 | removeStrategyConfigs.put("TIMEOUT","50"); 22 | } 23 | 24 | public BlackListConfig(boolean byDefault) { 25 | if (byDefault) { 26 | appendStrategy = new NormalAppend(); 27 | removeStrategy = new TimeoutRecover(); 28 | } 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "BlackListConfig{" + "removeStrategy=" + removeStrategy + ", appendStrategy=" 34 | + appendStrategy + '}'; 35 | } 36 | 37 | public String toJson() { 38 | StringBuilder json = new StringBuilder("\"OBLB_BLACKLIST\":{\n"); 39 | boolean atLeastOne = false; 40 | 41 | if (removeStrategy != null) { 42 | atLeastOne = true; 43 | json.append(removeStrategy.toJson()); 44 | } 45 | if (appendStrategy != null) { 46 | if (atLeastOne) { 47 | json.append(","); 48 | } 49 | json.append(appendStrategy.toJson()); 50 | } 51 | 52 | json.append("}"); 53 | return json.toString(); 54 | } 55 | 56 | public HashMap getRemoveStrategyConfigs() { 57 | return removeStrategyConfigs; 58 | } 59 | 60 | public void setRemoveStrategyConfigs(HashMap removeStrategyConfigs) { 61 | this.removeStrategyConfigs = removeStrategyConfigs; 62 | } 63 | 64 | public HashMap getAppendStrategyConfigs() { 65 | return appendStrategyConfigs; 66 | } 67 | 68 | public void setAppendStrategyConfigs(HashMap appendStrategyConfigs) { 69 | this.appendStrategyConfigs = appendStrategyConfigs; 70 | } 71 | 72 | public RemoveStrategy getRemoveStrategy() { 73 | return removeStrategy; 74 | } 75 | 76 | public void setRemoveStrategy(RemoveStrategy removeStrategy) { 77 | this.removeStrategy = removeStrategy; 78 | } 79 | 80 | public AppendStrategy getAppendStrategy() { 81 | return appendStrategy; 82 | } 83 | 84 | public void setAppendStrategy(AppendStrategy appendStrategy) { 85 | this.appendStrategy = appendStrategy; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/append/AppendStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.BlackList.append; 2 | 3 | import java.util.Properties; 4 | 5 | import com.oceanbase.jdbc.HostAddress; 6 | 7 | public interface AppendStrategy { 8 | 9 | String toJson(); 10 | 11 | boolean needToAppend(HostAddress hostAddress, Properties properties); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/append/NormalAppend.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.BlackList.append; 2 | 3 | import java.util.Properties; 4 | 5 | import com.oceanbase.jdbc.HostAddress; 6 | import com.oceanbase.jdbc.internal.failover.BlackList.append.AppendStrategy; 7 | 8 | public class NormalAppend implements AppendStrategy { 9 | 10 | @Override 11 | public String toString() { 12 | return "NormalAppend{}"; 13 | } 14 | 15 | public String toJson() { 16 | return "\"APPEND_STRATEGY\":{\"NAME\":\"NORMAL\"}"; 17 | } 18 | 19 | @Override 20 | public boolean needToAppend(HostAddress hostAddress, Properties properties) { 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/recover/RemoveStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.BlackList.recover; 2 | 3 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 4 | 5 | public interface RemoveStrategy { 6 | 7 | String toJson(); 8 | 9 | boolean needToChangeStateInfo(HostStateInfo hostStateInfo); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/recover/TimeoutRecover.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.BlackList.recover; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.RemoveStrategy; 6 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 7 | 8 | public class TimeoutRecover implements RemoveStrategy { 9 | long timeout; 10 | 11 | public TimeoutRecover() { 12 | this.timeout = 50; 13 | } 14 | 15 | public TimeoutRecover(long timeout) { 16 | this.timeout = timeout; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "TimeoutRecover{}"; 22 | } 23 | 24 | public String toJson() { 25 | return "\"REMOVE_STRATEGY\":{" + "\"NAME\":\"TIMEOUT\"," + "\"TIMEOUT\":" + timeout + "}"; 26 | } 27 | 28 | public long getTimeout() { 29 | return timeout; 30 | } 31 | 32 | public void setTimeout(long timeout) { 33 | this.timeout = timeout; 34 | } 35 | 36 | @Override 37 | public boolean needToChangeStateInfo(HostStateInfo hostStateInfo) { 38 | long currentTimeNanos = System.nanoTime(); 39 | long entryNanos = hostStateInfo.getTimestamp(); 40 | long durationSeconds = TimeUnit.NANOSECONDS.toSeconds(currentTimeNanos - entryNanos); 41 | if (durationSeconds >= timeout) { 42 | return true; 43 | } else { 44 | return false; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/BalanceStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentMap; 7 | 8 | import com.oceanbase.jdbc.HostAddress; 9 | import com.oceanbase.jdbc.UrlParser; 10 | import com.oceanbase.jdbc.internal.failover.Listener; 11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList; 12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter; 13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 14 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo; 15 | 16 | public interface BalanceStrategy { 17 | 18 | String toJson(); 19 | 20 | static boolean allBlack(List loopAddress, ConcurrentMap blacklist ) { 21 | if(blacklist.keySet().size() == 0) { 22 | return false; 23 | } 24 | if(!blacklist.keySet().containsAll(loopAddress)) { 25 | return false; 26 | } 27 | for(HostAddress hostAddress : blacklist.keySet()) { 28 | if (loopAddress.contains(hostAddress) && blacklist.get(hostAddress).getState() != HostStateInfo.STATE.BLACK) { 29 | return false; 30 | } 31 | } 32 | return true; 33 | } 34 | 35 | /** 36 | * Select a proper connection based on the current configuration information 37 | * @param loadBalanceAddressList current load balance config info 38 | * @param urlParser url parser,get options from it 39 | * @param listener current listener 40 | * @param globalInfo global info 41 | * @param searchFilter filter 42 | * @param blacklist current black host list 43 | * @throws SQLException 44 | */ 45 | void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser, 46 | Listener listener, final GlobalStateInfo globalInfo, 47 | SearchFilter searchFilter, 48 | ConcurrentMap blacklist, 49 | Set pickedList) throws SQLException; 50 | 51 | void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList, 52 | Listener listener, GlobalStateInfo globalInfo) 53 | throws SQLException; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/GroupBalanceStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentMap; 7 | 8 | import com.oceanbase.jdbc.HostAddress; 9 | import com.oceanbase.jdbc.UrlParser; 10 | import com.oceanbase.jdbc.internal.failover.Listener; 11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList; 12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter; 13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 14 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo; 15 | 16 | public interface GroupBalanceStrategy { 17 | 18 | String toJson(); 19 | 20 | void pickAddressList(List groups, UrlParser urlParser, 21 | Listener listener, final GlobalStateInfo globalInfo, 22 | SearchFilter searchFilter, 23 | ConcurrentMap blacklist, 24 | Set pickedList) throws SQLException; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/RandomStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy; 2 | 3 | import java.sql.SQLException; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.Set; 7 | import java.util.concurrent.ConcurrentMap; 8 | 9 | import com.oceanbase.jdbc.HostAddress; 10 | import com.oceanbase.jdbc.UrlParser; 11 | import com.oceanbase.jdbc.internal.failover.Listener; 12 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList; 13 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter; 14 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 15 | import com.oceanbase.jdbc.internal.logging.Logger; 16 | import com.oceanbase.jdbc.internal.logging.LoggerFactory; 17 | import com.oceanbase.jdbc.internal.protocol.MasterProtocol; 18 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo; 19 | 20 | public class RandomStrategy implements BalanceStrategy { 21 | private static final Logger logger = LoggerFactory.getLogger(RandomStrategy.class); 22 | 23 | public RandomStrategy() { 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "RandomStrategy{}"; 29 | } 30 | 31 | public String toJson() { 32 | return "\"OBLB_STRATEGY\":\"RANDOM\""; 33 | } 34 | 35 | @Override 36 | public void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser, 37 | Listener listener, GlobalStateInfo globalInfo, 38 | SearchFilter searchFilter, 39 | ConcurrentMap blacklist, 40 | Set pickedList) throws SQLException { 41 | 42 | List loopAddress = loadBalanceAddressList.convertToHostAddressList(); 43 | if (BalanceStrategy.allBlack(loopAddress, blacklist)) { 44 | throw new SQLException("No active connection found for master"); 45 | } else { 46 | // remove hosts which have been added to blacklist(but not grey list) in previous groups from current group 47 | for (HostAddress hostAddress : blacklist.keySet()) { 48 | if (loopAddress.contains(hostAddress) 49 | && blacklist.get(hostAddress).getState() == HostStateInfo.STATE.BLACK) { 50 | loopAddress.remove(hostAddress); 51 | } 52 | } 53 | } 54 | Collections.shuffle(loopAddress); 55 | logger.debug("Current black list : " + blacklist); 56 | logger.debug("Picked list : " + pickedList); 57 | logger.debug("LoopAddress : " + loopAddress); 58 | 59 | MasterProtocol.loop(listener, globalInfo, loopAddress); 60 | } 61 | 62 | public void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList, 63 | Listener listener, GlobalStateInfo globalInfo) 64 | throws SQLException { 65 | List loopAddress = loadBalanceAddressList.convertToHostAddressList(); 66 | Collections.shuffle(loopAddress); 67 | logger.debug("LoopAddress : " + loopAddress); 68 | MasterProtocol.loop(listener, globalInfo, loopAddress, true); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/RotationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentMap; 7 | 8 | import com.oceanbase.jdbc.HostAddress; 9 | import com.oceanbase.jdbc.UrlParser; 10 | import com.oceanbase.jdbc.internal.failover.Listener; 11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList; 12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter; 13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo; 14 | import com.oceanbase.jdbc.internal.logging.Logger; 15 | import com.oceanbase.jdbc.internal.logging.LoggerFactory; 16 | import com.oceanbase.jdbc.internal.protocol.MasterProtocol; 17 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo; 18 | 19 | public class RotationStrategy implements BalanceStrategy { 20 | private static final Logger logger = LoggerFactory.getLogger(RotationStrategy.class); 21 | 22 | public RotationStrategy() { 23 | 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "RotationStrategy{}"; 29 | } 30 | 31 | public String toJson() { 32 | return "\"OBLB_STRATEGY\":\"ROTATION\""; 33 | } 34 | 35 | @Override 36 | public void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser, 37 | Listener listener, GlobalStateInfo globalInfo, 38 | SearchFilter searchFilter, 39 | ConcurrentMap blacklist, 40 | Set pickedList) throws SQLException { 41 | List loopAddress = loadBalanceAddressList.convertToHostAddressList(); 42 | if (BalanceStrategy.allBlack(loopAddress, blacklist)) { 43 | throw new SQLException("No active connection found for master"); 44 | } else { 45 | // remove hosts which have been added to blacklist(but not grey list) in previous groups from current group 46 | for (HostAddress hostAddress : blacklist.keySet()) { 47 | if (loopAddress.contains(hostAddress) 48 | && blacklist.get(hostAddress).getState() == HostStateInfo.STATE.BLACK) { 49 | loopAddress.remove(hostAddress); 50 | } 51 | } 52 | } 53 | logger.debug("Current black list : " + blacklist); 54 | logger.debug("LoopAddress : " + loopAddress); 55 | MasterProtocol.loop(listener, globalInfo, loopAddress); 56 | } 57 | 58 | public void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList, 59 | Listener listener, GlobalStateInfo globalInfo) 60 | throws SQLException { 61 | List loopAddress = loadBalanceAddressList.convertToHostAddressList(); 62 | logger.debug("LoopAddress : " + loopAddress); 63 | MasterProtocol.loop(listener, globalInfo, loopAddress, true); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/LoadBalanceHostAddress.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl; 2 | 3 | import com.oceanbase.jdbc.HostAddress; 4 | 5 | public class LoadBalanceHostAddress extends HostAddress { 6 | private int weight; 7 | 8 | public LoadBalanceHostAddress(String host, int port) { 9 | super(host, port); 10 | } 11 | 12 | public LoadBalanceHostAddress(String host, int port, int weight) { 13 | super(host, port); 14 | this.weight = weight; 15 | } 16 | 17 | public LoadBalanceHostAddress(String host, int port, String type) { 18 | super(host, port, type); 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "LoadBalanceHostAddress{" + "weight=" + weight + ", host='" + host + '\'' 24 | + ", port=" + port + ", type='" + type + '\'' + '}'; 25 | } 26 | 27 | public String toJson() { 28 | StringBuilder json = new StringBuilder("\"HOST\":\"" + host + "\",\"PORT\":" + port); 29 | if (weight > 0) { 30 | json.append(",\"WEIGHT\":").append(weight); 31 | } 32 | return json.toString(); 33 | } 34 | 35 | public void setWeight(int weight) { 36 | this.weight = weight; 37 | } 38 | 39 | public int getWeight() { 40 | return weight; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BalanceStrategyChecker.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl.checkers; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.HashSet; 6 | 7 | public class BalanceStrategyChecker implements ConfigChecker { 8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME")); 9 | 10 | HashSet namesSet = new HashSet<>(Arrays.asList("ROTATION","RANDOM","SERVERAFFINITY","DEFAULT")); 11 | @Override 12 | public boolean isValid(HashMap config) { 13 | return keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BlackListStrategyAppendChecker.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl.checkers; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.HashSet; 6 | 7 | public class BlackListStrategyAppendChecker implements ConfigChecker { 8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME","RETRYTIMES","DURATION")); 9 | HashSet namesSet = new HashSet<>(Arrays.asList("RETRYDURATION","NORMAL")); 10 | @Override 11 | public boolean isValid(HashMap config) { 12 | if( keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")) ){ 13 | if(config.get("NAME") == "RETRYDURATION") { 14 | String retrytimes = config.get("RETRYTIMES"); 15 | try { 16 | int t = Integer.parseInt(retrytimes); 17 | if (t < 0) { 18 | return false; 19 | } 20 | } catch (NumberFormatException e) { 21 | return false; 22 | } 23 | String duration = config.get("DURATION"); 24 | try { 25 | int t = Integer.parseInt(duration); 26 | if (t < 0) { 27 | return false; 28 | } else { 29 | return true; 30 | } 31 | } catch (NumberFormatException e) { 32 | return false; 33 | } 34 | } else { 35 | return true; 36 | } 37 | } 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BlackListStrategyRemoveChecker.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl.checkers; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.HashSet; 6 | 7 | public class BlackListStrategyRemoveChecker implements ConfigChecker { 8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME","TIMEOUT")); 9 | HashSet namesSet = new HashSet<>(Arrays.asList("TIMEOUT")); 10 | @Override 11 | public boolean isValid(HashMap config) { 12 | if(keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")) ){ 13 | String timeout = config.get("TIMEOUT"); 14 | try { 15 | int t = Integer.parseInt(timeout); 16 | if(t<0) { 17 | return false; 18 | } else { 19 | return true; 20 | } 21 | } catch (NumberFormatException e) { 22 | return false; 23 | } 24 | } 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/ConfigChecker.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl.checkers; 2 | 3 | import java.util.HashMap; 4 | 5 | public interface ConfigChecker { 6 | boolean isValid(HashMap config); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/GroupStrategyConfigChecker.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.impl.checkers; 2 | 3 | import java.util.*; 4 | import java.util.HashSet; 5 | 6 | import com.oceanbase.jdbc.internal.failover.impl.checkers.ConfigChecker; 7 | 8 | public class GroupStrategyConfigChecker implements ConfigChecker { 9 | HashSet keySet = new HashSet<>(Arrays.asList("NAME")); 10 | HashSet namesSet = new HashSet<>(Arrays.asList("ROTATION")); 11 | 12 | 13 | @Override 14 | public boolean isValid(HashMap config) { 15 | return keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/utils/Consts.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.utils; 2 | 3 | public class Consts { 4 | // configure 5 | public static final String NAME = "NAME"; 6 | public static final String RETRYTIMES = "RETRYTIMES"; 7 | public static final String DURATION_MS = "DURATION"; 8 | public static final String TIMEOUT_MS = "TIMEOUT"; 9 | public static final String RETRYDURATION = "RETRYDURATION"; 10 | public static final String NORMAL = "NORMAL"; 11 | public static final String SERVERAFFINITY = "SERVERAFFINITY"; 12 | public static final String ROTATION = "ROTATION"; 13 | public static final String RANDOM = "RANDOM"; 14 | public static final String ON = "ON"; 15 | public static final String DEFAULT = "DEFAULT"; 16 | 17 | // blacklist 18 | public static final String FAILED_TIME_MS = "failedTime"; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/failover/utils/HostStateInfo.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.failover.utils; 2 | 3 | public class HostStateInfo { 4 | public enum STATE { 5 | GREY, 6 | BLACK 7 | } 8 | 9 | STATE state; 10 | Long timestamp; 11 | 12 | public HostStateInfo() { 13 | state = STATE.BLACK; 14 | timestamp = System.nanoTime(); 15 | } 16 | 17 | public HostStateInfo(STATE state, Long timestamp) { 18 | this.state = state; 19 | this.timestamp = timestamp; 20 | } 21 | 22 | public STATE getState() { 23 | return state; 24 | } 25 | 26 | public void setState(STATE state) { 27 | this.state = state; 28 | } 29 | 30 | public Long getTimestamp() { 31 | return timestamp; 32 | } 33 | 34 | public void setTimestamp(Long timestamp) { 35 | this.timestamp = timestamp; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "HostStateInfo{" + "state=" + state + ", timestamp=" + timestamp + '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/io/socket/SocketHandlerFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.io.socket; 52 | 53 | import java.io.IOException; 54 | import java.net.Socket; 55 | 56 | import com.oceanbase.jdbc.util.Options; 57 | 58 | @FunctionalInterface 59 | public interface SocketHandlerFunction { 60 | 61 | Socket apply(Options options, String host) throws IOException; 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/BulkStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util; 52 | 53 | public class BulkStatus { 54 | 55 | public volatile int sendSubCmdCounter; 56 | public volatile boolean sendEnded; 57 | public int sendCmdCounter = 0; 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/ConnectionState.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util; 52 | 53 | public class ConnectionState { 54 | 55 | public static final int STATE_NETWORK_TIMEOUT = 1; 56 | public static final int STATE_DATABASE = 2; 57 | public static final int STATE_READ_ONLY = 4; 58 | public static final int STATE_AUTOCOMMIT = 8; 59 | public static final int STATE_TRANSACTION_ISOLATION = 16; 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/DeRegister.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util; 52 | 53 | import java.sql.DriverAction; 54 | 55 | import com.oceanbase.jdbc.internal.util.scheduler.SchedulerServiceProviderHolder; 56 | 57 | public class DeRegister implements DriverAction { 58 | 59 | @Override 60 | public void deregister() { 61 | SchedulerServiceProviderHolder.close(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/LRUCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util; 52 | 53 | import java.util.LinkedHashMap; 54 | import java.util.Map; 55 | 56 | public class LRUCache extends LinkedHashMap { 57 | private static final long serialVersionUID = 1L; 58 | protected int maxElements; 59 | 60 | public LRUCache(int maxSize) { 61 | super(maxSize, 0.75F, true); 62 | this.maxElements = maxSize; 63 | } 64 | 65 | /* 66 | * (non-Javadoc) 67 | * 68 | * @see java.util.LinkedHashMap#removeEldestEntry(java.util.Map.Entry) 69 | */ 70 | @Override 71 | protected boolean removeEldestEntry(Map.Entry eldest) { 72 | return (size() > this.maxElements); 73 | } 74 | } -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/ParsedCallParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | 45 | package com.oceanbase.jdbc.internal.util; 46 | 47 | public class ParsedCallParameters { 48 | private boolean isParam; 49 | private String name; 50 | 51 | public ParsedCallParameters(boolean isParam, String name) { 52 | this.isParam = isParam; 53 | this.name = name; 54 | } 55 | 56 | public boolean isParam() { 57 | return isParam; 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/ResourceStatus.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc.internal.util; 2 | 3 | public enum ResourceStatus { 4 | OPEN, 5 | CLOSING, 6 | CLOSED 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/constant/ColumnFlags.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.constant; 52 | 53 | public class ColumnFlags { 54 | 55 | public static final short NOT_NULL = 1; 56 | public static final short PRIMARY_KEY = 2; 57 | public static final short UNIQUE_KEY = 4; 58 | public static final short MULTIPLE_KEY = 8; 59 | public static final short BLOB = 16; 60 | public static final short UNSIGNED = 32; 61 | public static final short DECIMAL = 64; 62 | public static final short BINARY_COLLATION = 128; 63 | public static final short ENUM = 256; 64 | public static final short AUTO_INCREMENT = 512; 65 | public static final short TIMESTAMP = 1024; 66 | public static final short SET = 2048; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/constant/HaMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.constant; 52 | 53 | public enum HaMode { 54 | AURORA, 55 | REPLICATION, 56 | SEQUENTIAL, 57 | LOADBALANCE, 58 | NONE 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/constant/ParameterConstant.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.constant; 52 | 53 | public class ParameterConstant { 54 | 55 | public static final String TYPE_MASTER = "master"; 56 | public static final String TYPE_SLAVE = "slave"; 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/constant/StateChange.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.constant; 52 | 53 | public class StateChange { 54 | 55 | public static final short SESSION_TRACK_SYSTEM_VARIABLES = 0; 56 | public static final short SESSION_TRACK_SCHEMA = 1; 57 | public static final short SESSION_TRACK_STATE_CHANGE = 2; 58 | public static final short SESSION_TRACK_GTIDS = 3; 59 | public static final short SESSION_TRACK_TRANSACTION_CHARACTERISTICS = 4; 60 | public static final short SESSION_TRACK_TRANSACTION_STATE = 5; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/dao/CloneableCallableStatement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.dao; 52 | 53 | import java.sql.CallableStatement; 54 | 55 | import com.oceanbase.jdbc.OceanBaseConnection; 56 | 57 | public interface CloneableCallableStatement extends CallableStatement { 58 | 59 | CloneableCallableStatement clone(OceanBaseConnection connection) 60 | throws CloneNotSupportedException; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/dao/Identifier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.dao; 52 | 53 | /* 54 | Identifier, i.e table, or column name. Put into ` quotes in SHOW CREATE TABLE. Can be "multi-part", i.e `schema`.`table` 55 | */ 56 | public class Identifier { 57 | 58 | public String schema; 59 | public String name; 60 | 61 | /** 62 | * Identifier string value. 63 | * 64 | * @return the datas. 65 | */ 66 | public String toString() { 67 | if (schema != null) { 68 | return schema + "." + name; 69 | } 70 | return name; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/dao/PrepareResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.dao; 52 | 53 | public interface PrepareResult { 54 | 55 | String getSql(); 56 | 57 | int getParamCount(); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/dao/ReconnectDuringTransactionException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.dao; 52 | 53 | import java.sql.SQLException; 54 | 55 | public class ReconnectDuringTransactionException extends SQLException { 56 | 57 | public ReconnectDuringTransactionException(String message, int errorCode, String sqlState) { 58 | super(message, sqlState, errorCode); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/exceptions/MaxAllowedPacketException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.exceptions; 52 | 53 | import java.io.IOException; 54 | 55 | public class MaxAllowedPacketException extends IOException { 56 | 57 | private final boolean mustReconnect; 58 | 59 | public MaxAllowedPacketException(String message, boolean mustReconnect) { 60 | super(message); 61 | this.mustReconnect = mustReconnect; 62 | } 63 | 64 | public boolean isMustReconnect() { 65 | return mustReconnect; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/exceptions/OceanBaseDataTruncation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.internal.util.exceptions; 45 | 46 | import java.sql.DataTruncation; 47 | 48 | public class OceanBaseDataTruncation extends DataTruncation { 49 | String errorMessage; 50 | int errorCode; 51 | 52 | public OceanBaseDataTruncation(int index, boolean parameter, boolean read, int dataSize, 53 | int transferSize, Throwable cause, String errorMessage, 54 | int errorCode) { 55 | super(index, parameter, read, dataSize, transferSize, cause); 56 | this.errorMessage = errorMessage; 57 | this.errorCode = errorCode; 58 | } 59 | 60 | @Override 61 | public int getErrorCode() { 62 | return this.errorCode; 63 | } 64 | 65 | @Override 66 | public String getMessage() { 67 | return super.getMessage() + ": " + this.errorMessage; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/pool/PoolMBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.pool; 52 | 53 | public interface PoolMBean { 54 | 55 | long getActiveConnections(); 56 | 57 | long getTotalConnections(); 58 | 59 | long getIdleConnections(); 60 | 61 | long getConnectionRequests(); 62 | 63 | void resetStaticGlobal(); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/scheduler/DynamicSizedSchedulerInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.scheduler; 52 | 53 | import java.util.concurrent.ScheduledExecutorService; 54 | 55 | public interface DynamicSizedSchedulerInterface extends ScheduledExecutorService { 56 | 57 | /** 58 | * Update the pool thread count with this new value. 59 | * 60 | * @param newSize New pool size that is superior to 0 61 | */ 62 | void setPoolSize(int newSize); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/internal/util/scheduler/FixedSizedSchedulerImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.internal.util.scheduler; 52 | 53 | import java.util.concurrent.ScheduledThreadPoolExecutor; 54 | 55 | public class FixedSizedSchedulerImpl extends ScheduledThreadPoolExecutor { 56 | 57 | /** 58 | * Create scheduler with fixed size. 59 | * 60 | * @param corePoolSize core pool size 61 | * @param poolName name of pool to identify threads 62 | */ 63 | public FixedSizedSchedulerImpl(int corePoolSize, String poolName) { 64 | super(corePoolSize, new OceanBaseThreadFactory(poolName)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/jdbc2/optional/MysqlXAConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.jdbc2.optional; 45 | 46 | import com.oceanbase.jdbc.OceanBaseConnection; 47 | import com.oceanbase.jdbc.OceanBaseXaConnection; 48 | 49 | public class MysqlXAConnection extends OceanBaseXaConnection { 50 | public MysqlXAConnection(OceanBaseConnection connection) { 51 | super(connection); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/jdbc2/optional/MysqlXAResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.jdbc2.optional; 45 | 46 | import com.oceanbase.jdbc.OceanBaseConnection; 47 | import com.oceanbase.jdbc.OceanBaseXaResource; 48 | 49 | public class MysqlXAResource extends OceanBaseXaResource { 50 | 51 | public MysqlXAResource(OceanBaseConnection connection) { 52 | super(connection); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/jdbc2/optional/MysqlXid.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc.jdbc2.optional; 52 | 53 | import com.oceanbase.jdbc.OceanBaseXid; 54 | 55 | /** 56 | * Compatible with Mysql Connector J interface MysqlXid 57 | */ 58 | public class MysqlXid extends OceanBaseXid { 59 | 60 | public MysqlXid(byte[] globalTransactionId, byte[] branchQualifier, int formatId) { 61 | super(globalTransactionId, branchQualifier, formatId); 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/com/oceanbase/jdbc/util/ConfigurableSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc.util; 45 | 46 | import javax.net.SocketFactory; 47 | 48 | public abstract class ConfigurableSocketFactory extends SocketFactory { 49 | public abstract void setConfiguration(Options options, String host); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/com.oceanbase.jdbc.authentication.AuthenticationPlugin: -------------------------------------------------------------------------------- 1 | com.oceanbase.jdbc.internal.com.send.authentication.ClearPasswordPlugin 2 | com.oceanbase.jdbc.internal.com.send.authentication.SendGssApiAuthPacket 3 | com.oceanbase.jdbc.internal.com.send.authentication.Ed25519PasswordPlugin 4 | com.oceanbase.jdbc.internal.com.send.authentication.NativePasswordPlugin 5 | com.oceanbase.jdbc.internal.com.send.authentication.OldPasswordPlugin 6 | com.oceanbase.jdbc.internal.com.send.authentication.SendPamAuthPacket 7 | com.oceanbase.jdbc.internal.com.send.authentication.Sha256PasswordPlugin 8 | com.oceanbase.jdbc.internal.com.send.authentication.CachingSha2PasswordPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/com.oceanbase.jdbc.credential.CredentialPlugin: -------------------------------------------------------------------------------- 1 | com.oceanbase.jdbc.credential.env.EnvCredentialPlugin 2 | com.oceanbase.jdbc.credential.system.PropertiesCredentialPlugin 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/com.oceanbase.jdbc.tls.TlsSocketPlugin: -------------------------------------------------------------------------------- 1 | com.oceanbase.jdbc.internal.protocol.tls.DefaultTlsSocketPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/java.sql.Driver: -------------------------------------------------------------------------------- 1 | com.oceanbase.jdbc.Driver -------------------------------------------------------------------------------- /src/main/resources/oceanbase.properties: -------------------------------------------------------------------------------- 1 | version=${project.version} -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/CharsetOracleTest.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import java.sql.Connection; 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | import java.sql.Statement; 10 | 11 | public class CharsetOracleTest extends BaseOracleTest{ 12 | 13 | @Test 14 | public void testHKSCSForDima2024062200102857062() throws SQLException { 15 | Connection conn = sharedConnection; 16 | Statement stmt = conn.createStatement(); 17 | createTable("t_c1", "c1 varchar2(60)"); 18 | stmt.execute("insert into t_c1 values('嘅_係_嘢_冇_咁_镬_嘥_1')"); 19 | ResultSet rs = stmt.executeQuery("select * from t_c1"); 20 | Assert.assertTrue(rs.next()); 21 | Assert.assertEquals("嘅_係_嘢_冇_咁_?_嘥_1", rs.getString(1)); 22 | 23 | conn = setConnection("&characterEncoding=HKSCS"); 24 | createTable("t_c2", "c1 varchar2(60)"); 25 | stmt = conn.createStatement(); 26 | stmt.execute("insert into t_c2 values('嘅_係_嘢_冇_咁_镬_嘥_2')"); 27 | rs = stmt.executeQuery("select * from t_c2"); 28 | Assert.assertTrue(rs.next()); 29 | Assert.assertEquals("嘅_係_嘢_冇_咁_镬_嘥_2", rs.getString(1)); 30 | } 31 | 32 | @Test 33 | public void testHKSCS31ForDima2024062200102857062() throws SQLException { 34 | Connection conn = sharedConnection; 35 | Statement stmt = conn.createStatement(); 36 | createTable("t_c1", "c1 varchar2(60)"); 37 | stmt.execute("insert into t_c1 values('嘅_係_嘢_冇_咁_镬_嘥_1')"); 38 | ResultSet rs = stmt.executeQuery("select * from t_c1"); 39 | Assert.assertTrue(rs.next()); 40 | Assert.assertEquals("嘅_係_嘢_冇_咁_?_嘥_1", rs.getString(1)); 41 | 42 | conn = setConnection("&characterEncoding=HKSCS31"); 43 | createTable("t_c2", "c1 varchar2(60)"); 44 | stmt = conn.createStatement(); 45 | stmt.execute("insert into t_c2 values('嘅_係_嘢_冇_咁_镬_嘥_2')"); 46 | rs = stmt.executeQuery("select * from t_c2"); 47 | Assert.assertTrue(rs.next()); 48 | Assert.assertEquals("嘅_係_嘢_冇_咁_镬_嘥_2", rs.getString(1)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/ComMultiPrepareStatementTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.sql.PreparedStatement; 47 | 48 | public class ComMultiPrepareStatementTest extends BaseTest { 49 | 50 | @org.junit.Test 51 | public void insertSelectTempTable2() throws Exception { 52 | // requireMinimumVersion(10, 2); 53 | createTable("test_insert_select_com_multi", "`field1` varchar(20)"); 54 | // prepare doesn't work. 55 | PreparedStatement stmt = sharedConnection 56 | .prepareStatement("select TMP.field1 from (select CAST(? as binary) `field1` from dual) TMP"); 57 | stmt.setString(1, "test"); 58 | stmt.executeUpdate(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/ComplexScenarioTestCases.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.sql.*; 6 | 7 | import org.junit.Assert; 8 | import org.junit.Assume; 9 | import org.junit.Test; 10 | 11 | public class ComplexScenarioTestCases extends BaseTest { 12 | @Test 13 | public void testSocksProxy() { 14 | try { 15 | String url = System.getProperty("socksProxyOptions"); 16 | Connection connection = setConnection(url); 17 | ResultSet resultSet = connection.createStatement().executeQuery("select 1"); 18 | Assert.assertTrue(resultSet.next()); 19 | Assert.assertEquals(1, resultSet.getInt(1)); 20 | } catch (SQLException e) { 21 | Assert.fail(); 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | @Test 27 | public void testChangeUser() { 28 | try { 29 | String observerUrl = System.getProperty("observerUrl"); 30 | Assume.assumeNotNull(observerUrl); 31 | String user = System.getProperty("newUser"); 32 | String password = System.getProperty("newPwd"); 33 | System.out.println("observerUrl = " + observerUrl); 34 | Connection conn = DriverManager.getConnection(observerUrl); 35 | ((ObConnection) conn).changeUser(user, password); 36 | Statement stmt = conn.createStatement(); 37 | stmt.execute("drop table if exists test_change_user"); 38 | stmt.execute("create table test_change_user(c1 int);"); 39 | stmt.execute("insert into test_change_user values(100)"); 40 | ResultSet rs = stmt.executeQuery("select * from test_change_user"); 41 | Assert.assertTrue(rs.next()); 42 | Assert.assertEquals(100, rs.getInt(1)); 43 | conn.close(); 44 | } catch (SQLException e) { 45 | e.printStackTrace(); 46 | Assert.fail(); 47 | } 48 | } 49 | 50 | @Test 51 | public void testConnectProxy() { 52 | try { 53 | String url = System.getProperty("connectProxyUrl"); 54 | Class.forName("com.oceanbase.jdbc.Driver"); 55 | Connection conn = DriverManager.getConnection(url); 56 | Statement statement = conn.createStatement(); 57 | try { 58 | statement.execute("alter proxyconfig set enable_client_ssl=true;"); 59 | statement.execute("alter proxyconfig set enable_client_ssl=false;"); 60 | } catch (Exception e) { 61 | e.printStackTrace(); 62 | } 63 | ResultSet rs = statement.executeQuery("show proxyconfig"); 64 | int count = rs.getMetaData().getColumnCount(); 65 | int rowCount = 0; 66 | while (rs.next()) { 67 | for (int i = 1; i <= count; i++) { 68 | System.out.println(" col[ " + i + "] =" + rs.getString(i)); 69 | } 70 | rowCount++; 71 | } 72 | Assert.assertNotEquals(rowCount, 0); 73 | } catch (ClassNotFoundException e) { 74 | e.printStackTrace(); 75 | Assert.fail(); 76 | } catch (SQLException e) { 77 | e.printStackTrace(); 78 | Assert.fail(); 79 | 80 | } 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/LocalInfileInterceptorImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | public class LocalInfileInterceptorImpl implements LocalInfileInterceptor { 47 | 48 | @Override 49 | public boolean validate(String fileName) { 50 | return fileName != null && (fileName.length() > 0); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/OceanBaseXaResourceTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * OceanBase Client for Java 3 | * 4 | * Copyright (c) 2012-2014 Monty Program Ab. 5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | * Copyright (c) 2021 OceanBase. 7 | * 8 | * This library is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU Lesser General Public License as published by the Free 10 | * Software Foundation; either version 2.1 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License along 19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | * 21 | * This particular MariaDB Client for Java file is work 22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | * the following copyright and notice provisions: 24 | * 25 | * Copyright (c) 2009-2011, Marcus Eriksson 26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * Redistributions of source code must retain the above copyright notice, this list 30 | * of conditions and the following disclaimer. 31 | * 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | * list of conditions and the following disclaimer in the documentation and/or 34 | * other materials provided with the distribution. 35 | * 36 | * Neither the name of the driver nor the names of its contributors may not be 37 | * used to endorse or promote products derived from this software without specific 38 | * prior written permission. 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | * OF SUCH DAMAGE. 50 | */ 51 | package com.oceanbase.jdbc; 52 | 53 | import static org.junit.Assert.assertEquals; 54 | 55 | import org.junit.Test; 56 | 57 | public class OceanBaseXaResourceTest { 58 | @Test 59 | public void xidToString() { 60 | assertEquals("0x00,0x01,0x05", OceanBaseXaResource.xidToString(new OceanBaseXid(5, 61 | new byte[] { 0x00 }, new byte[] { 0x01 }))); 62 | assertEquals( 63 | "0x,0x000100,0x0400", 64 | OceanBaseXaResource.xidToString(new OceanBaseXid(1024, new byte[] {}, new byte[] { 65 | 0x00, 0x01, 0x00 }))); 66 | assertEquals("0x00,0x000100,0xC3C20186", OceanBaseXaResource.xidToString(new OceanBaseXid( 67 | -1010695802, new byte[] { 0x00 }, new byte[] { 0x00, 0x01, 0x00 }))); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/SerializableClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * OceanBase Client for Java 4 | * 5 | * Copyright (c) 2021 OceanBase. 6 | * 7 | * This library is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation; either version 2.1 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * Copyright (c) 2009-2011, Marcus Eriksson 18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * Redistributions of source code must retain the above copyright notice, this list 22 | * of conditions and the following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above copyright notice, this 25 | * list of conditions and the following disclaimer in the documentation and/or 26 | * other materials provided with the distribution. 27 | * 28 | * Neither the name of the driver nor the names of its contributors may not be 29 | * used to endorse or promote products derived from this software without specific 30 | * prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 41 | * OF SUCH DAMAGE. 42 | * 43 | */ 44 | package com.oceanbase.jdbc; 45 | 46 | import java.io.Serializable; 47 | 48 | public class SerializableClass implements Serializable { 49 | 50 | private static final long serialVersionUID = 4625959895106940108L; 51 | private final String val; 52 | private final int val2; 53 | 54 | public SerializableClass(String val, int val2) { 55 | this.val = val; 56 | this.val2 = val2; 57 | } 58 | 59 | public String getVal() { 60 | return val; 61 | } 62 | 63 | public int getVal2() { 64 | return val2; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/com/oceanbase/jdbc/UpdateResultSetOracleTest.java: -------------------------------------------------------------------------------- 1 | package com.oceanbase.jdbc; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.sql.*; 6 | 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | 10 | public class UpdateResultSetOracleTest extends BaseOracleTest { 11 | 12 | @Test 13 | public void test1() throws SQLException { 14 | createTable("ResultSetTypePRIMARY", 15 | "c1 INT, c2 VARCHAR2(100), constraint pk primary key(c1)"); 16 | Statement stmt = sharedConnection.createStatement(); 17 | stmt.execute("insert into ResultSetTypePRIMARY values(1, 'var1')"); // cmd_query 18 | 19 | Connection conn = setConnectionOrigin("?useServerPrepStmts=true&useOraclePrepareExecute=true"); 20 | PreparedStatement pstmt = conn 21 | .prepareStatement("insert into ResultSetTypePRIMARY values(?, ?)"); 22 | 23 | pstmt.setInt(1, 2); 24 | pstmt.setString(2, "var2"); 25 | pstmt.execute(); 26 | 27 | pstmt.setInt(1, 3); 28 | pstmt.setString(2, "var3"); 29 | pstmt.executeQuery(); 30 | 31 | PreparedStatement ps = conn.prepareStatement(" /**/SELECT c1,c2 FROM ResultSetTypePRIMARY", 32 | ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 33 | ResultSet rs = ps.executeQuery(); 34 | assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, rs.getType()); 35 | assertEquals(ResultSet.CONCUR_UPDATABLE, rs.getConcurrency()); 36 | assertEquals("ROWID", rs.getMetaData().getColumnName(0)); 37 | int i = 1; 38 | while (rs.next()) { 39 | assertEquals(i++, rs.getInt(1)); 40 | } 41 | 42 | pstmt = conn.prepareStatement("delete from ResultSetTypePRIMARY where c1=?"); 43 | pstmt.setInt(1, 1); 44 | pstmt.executeQuery(); 45 | } 46 | 47 | @Test 48 | public void testDefaultPrimaryKey() throws Exception { 49 | createTable("testUpdatedAbleInsert", "c1 int , c2 int , c3 int, PRIMARY KEY (c1, c2)"); 50 | 51 | Statement stmt = sharedConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, 52 | ResultSet.CONCUR_UPDATABLE); 53 | ResultSet rs = stmt.executeQuery("SELECT c1, c2, c3 FROM testUpdatedAbleInsert"); 54 | 55 | rs.moveToInsertRow(); 56 | rs.updateInt("c1", 1); 57 | // rs.updateInt("c2", 1); 58 | rs.updateInt("c3", 1); 59 | try { 60 | rs.insertRow(); 61 | } catch (SQLException e) { 62 | Assert.assertTrue(e.getMessage().contains("ORA-01400: cannot insert NULL into '(C2)'")); 63 | } 64 | 65 | PreparedStatement ps = sharedPSConnection.prepareStatement( 66 | "SELECT c1, c2, c3 FROM testUpdatedAbleInsert", ResultSet.TYPE_SCROLL_INSENSITIVE, 67 | ResultSet.CONCUR_UPDATABLE); 68 | rs = ps.executeQuery(); 69 | 70 | rs.moveToInsertRow(); 71 | rs.updateInt("c1", 2); 72 | // rs.updateInt("c2", 1); 73 | rs.updateInt("c3", 2); 74 | try { 75 | rs.insertRow(); 76 | } catch (SQLException e) { 77 | Assert.assertTrue(e.getMessage().contains("ORA-01400: cannot insert NULL into '(C2)'")); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/services/com.oceanbase.jdbc.LocalInfileInterceptor: -------------------------------------------------------------------------------- 1 | com.oceanbase.jdbc.LocalInfileInterceptorImpl -------------------------------------------------------------------------------- /src/test/resources/conf.properties: -------------------------------------------------------------------------------- 1 | DB_HOST=localhost 2 | DB_PORT=3306 3 | DB_DATABASE=testj 4 | DB_USER=root 5 | DB_PASSWORD= -------------------------------------------------------------------------------- /src/test/resources/localInfile.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | OceanBase Client for Java 3 | 4 | Copyright (c) 2012-2014 Monty Program Ab. 5 | Copyright (c) 2015-2020 MariaDB Corporation Ab. 6 | Copyright (c) 2021 OceanBase. 7 | 8 | This library is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License as published by the Free 10 | Software Foundation; either version 2.1 of the License, or (at your option) 11 | any later version. 12 | 13 | This library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License along 19 | with this library; if not, write to Monty Program Ab info@montyprogram.com. 20 | 21 | This particular MariaDB Client for Java file is work 22 | derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to 23 | the following copyright and notice provisions: 24 | 25 | Copyright (c) 2009-2011, Marcus Eriksson 26 | 27 | Redistribution and use in source and binary forms, with or without modification, 28 | are permitted provided that the following conditions are met: 29 | Redistributions of source code must retain the above copyright notice, this list 30 | of conditions and the following disclaimer. 31 | 32 | Redistributions in binary form must reproduce the above copyright notice, this 33 | list of conditions and the following disclaimer in the documentation and/or 34 | other materials provided with the distribution. 35 | 36 | Neither the name of the driver nor the names of its contributors may not be 37 | used to endorse or promote products derived from this software without specific 38 | prior written permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 44 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 49 | OF SUCH DAMAGE. 50 | ==== 51 | 52 | 1,"hello" 53 | 2,"world" 54 | -------------------------------------------------------------------------------- /src/test/resources/ssl/README: -------------------------------------------------------------------------------- 1 | # The file wrong-server.crt is a valid PEM file for testing using the 2 | # the wrong certificate to connect to a server. To generate a new 3 | # certificate for testing run the following commands and copy the 4 | # resulting server.crt file to "wrong-server.crt" 5 | 6 | # Create certificate (will prompt for password): 7 | openssl genrsa -des3 -out server.key.secure 2048 8 | 9 | # Create password-less cert: 10 | openssl rsa -in server.key.secure -out server.key 11 | 12 | # Create signing request: 13 | openssl req -new -key server.key -out server.csr 14 | 15 | # Create self signed cert: 16 | openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt 17 | -------------------------------------------------------------------------------- /src/test/resources/ssl/wrong-server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDdjCCAl4CCQDLKi+rmQABYjANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJB 3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTE7MDkGA1UECgwyU2FtcGxlIENlcnRpZmlj 4 | YXRlIGZvciBNYXJpYURCIEphdmEgQ2xpZW50IFRlc3RpbmcxHDAaBgNVBAMME21h 5 | cmlhZGIuZXhhbXBsZS5vcmcwHhcNMTMwNjIzMjEwNTM3WhcNMjMwNjIxMjEwNTM3 6 | WjB9MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTE7MDkGA1UECgwy 7 | U2FtcGxlIENlcnRpZmljYXRlIGZvciBNYXJpYURCIEphdmEgQ2xpZW50IFRlc3Rp 8 | bmcxHDAaBgNVBAMME21hcmlhZGIuZXhhbXBsZS5vcmcwggEiMA0GCSqGSIb3DQEB 9 | AQUAA4IBDwAwggEKAoIBAQDbs2HMKguBwp4iNjYX0rKxYeTyUzW1JqQGBKL1LUhM 10 | EHDW9yOYpoNsrOpoH58mQC+h+FfwEdZr3O4DLmUQnryohOhzfdc6a/4mXgx+7Cnm 11 | Y1AgA14cxIRK7ziNJawURyHvLyEmHuoi3e9bJWPRt7b8OIsoftuxpyQ3CIvhah7o 12 | ZP2EY5DQWeieWuE9H27vYyimWpweAFB7SQ9Mg42yM/a3qiubmtLVoV2vcli62tck 13 | /hLxbsSOzM4vVTf7qTPui0wWsqWImz1QSN2SwRh6icPxs5GKqFcNFGyRkXrxj4lE 14 | sMfcFPDDLnpmT/PKdPLA38qSAe9M/YJHXw+oz73dB0XJAgMBAAEwDQYJKoZIhvcN 15 | AQEFBQADggEBAA8fo4b409d0s3pFbqNmx/LoA1RHG7/rbYaVW7mh327MDNN6BAZr 16 | 2pg1PoldAgKP6BZPKb/iwLkebv7axya8XE2h4p6aC5PPw4REvClW6/SVVfc3vhAs 17 | 4yzIG8x7LYkmCDRDcLseov+GpsqeKOEhIyWHEYVDuXLhQkSenL16Fv4c4IYR0xyX 18 | 6cvA9v/wpQLU4vRAQw8gEJWj3xAVnhWNm4MUCxrVewJtw2HK/2YVFysWw5r65+oZ 19 | PT/nVjCkkrQZsXnoLVRmVNG480ajLCKAYDD6DVd345njkVdDyWJa+9noq+542MEv 20 | GpAkl0yrTcd/AXgdYNyzNec0ZBmWZv6B/MY= 21 | -----END CERTIFICATE----- 22 | --------------------------------------------------------------------------------