├── vertx-pg-client ├── src │ ├── main │ │ ├── asciidoc │ │ │ └── override.adoc │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.vertx.sqlclient.spi.Driver │ │ └── java │ │ │ ├── io │ │ │ └── vertx │ │ │ │ └── pgclient │ │ │ │ ├── impl │ │ │ │ ├── codec │ │ │ │ │ ├── OutboundMessage.java │ │ │ │ │ ├── SyncMessage.java │ │ │ │ │ ├── ParseMessage.java │ │ │ │ │ ├── ExecuteMessage.java │ │ │ │ │ ├── TerminateMessage.java │ │ │ │ │ ├── ClosePortalMessage.java │ │ │ │ │ ├── ClosePreparedStatementMessage.java │ │ │ │ │ ├── TxFailedEvent.java │ │ │ │ │ ├── NoticeResponse.java │ │ │ │ │ ├── ScramClientFinalMessage.java │ │ │ │ │ ├── QueryMessage.java │ │ │ │ │ ├── ScramClientInitialMessage.java │ │ │ │ │ ├── DataFormat.java │ │ │ │ │ ├── DescribeMessage.java │ │ │ │ │ ├── PasswordMessage.java │ │ │ │ │ ├── BindMessage.java │ │ │ │ │ └── ClosePortalPgCommandMessage.java │ │ │ │ ├── auth │ │ │ │ │ └── scram │ │ │ │ │ │ └── ScramAuthentication.java │ │ │ │ ├── PgPoolOptions.java │ │ │ │ └── PgDatabaseMetadata.java │ │ │ │ ├── package-info.java │ │ │ │ └── data │ │ │ │ └── Cidr.java │ │ │ └── module-info.java │ └── test │ │ ├── resources │ │ ├── pgBouncer │ │ │ ├── userlist.txt │ │ │ ├── pgbouncer.ini │ │ │ └── Dockerfile │ │ └── tls │ │ │ ├── force_ssl.sh │ │ │ ├── ssl.sh │ │ │ ├── server.key │ │ │ └── another.crt │ │ └── java │ │ ├── io │ │ └── vertx │ │ │ └── tests │ │ │ └── pgclient │ │ │ ├── context │ │ │ ├── EventLoopContextTest.java │ │ │ ├── WorkerContextTest.java │ │ │ └── DuplicateContextTest.java │ │ │ ├── tck │ │ │ ├── PgPreparedQueryPooledTest.java │ │ │ ├── PgCollectorTest.java │ │ │ ├── PgPreparedBatchTest.java │ │ │ ├── PgPreparedQueryCachedTest.java │ │ │ ├── PgPreparedQueryTest.java │ │ │ ├── PgConnectionTest.java │ │ │ └── PgSimpleQueryTest.java │ │ │ ├── impl │ │ │ ├── MD5AuthenticationTest.java │ │ │ └── PgRowTest.java │ │ │ ├── data │ │ │ ├── UUIDTypeSimpleCodecTest.java │ │ │ ├── BooleanTypeSimpleCodecTest.java │ │ │ ├── NullSimpleCodecTest.java │ │ │ └── DataTypeCodecTest.java │ │ │ └── ErrorCodes.java │ │ └── module-info.java └── docker │ ├── postgres_tc │ ├── Dockerfile │ └── README.md │ └── postgres │ ├── README.md │ └── docker-compose.yml ├── vertx-sql-client-codec └── src │ ├── main │ ├── asciidoc │ │ └── index.adoc │ └── java │ │ ├── module-info.java │ │ └── io │ │ └── vertx │ │ └── sqlclient │ │ └── codec │ │ ├── InvalidCachedStatementEvent.java │ │ ├── CommandMessage.java │ │ └── CommandResponse.java │ └── test │ └── java │ └── module-info.java ├── vertx-db2-client ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.vertx.sqlclient.spi.Driver │ │ ├── java │ │ │ ├── io │ │ │ │ └── vertx │ │ │ │ │ └── db2client │ │ │ │ │ ├── impl │ │ │ │ │ ├── codec │ │ │ │ │ │ ├── ConnectionState.java │ │ │ │ │ │ ├── AuthenticationDB2CommandBaseMessage.java │ │ │ │ │ │ └── DB2ColumnDesc.java │ │ │ │ │ ├── command │ │ │ │ │ │ └── PingCommand.java │ │ │ │ │ ├── Db2PoolOptions.java │ │ │ │ │ └── drda │ │ │ │ │ │ └── CCSIDConstants.java │ │ │ │ │ └── package-info.java │ │ │ └── module-info.java │ │ └── generated │ │ │ └── io │ │ │ └── vertx │ │ │ └── db2client │ │ │ └── DB2ConnectOptionsConverter.java │ └── test │ │ ├── resources │ │ ├── tls │ │ │ ├── db2-keystore.p12 │ │ │ ├── server │ │ │ │ ├── server.kdb │ │ │ │ └── server.sth │ │ │ └── db2_tls_setup.sh │ │ ├── log4j.properties │ │ └── vertx-default-jul-logging.properties │ │ └── java │ │ └── io │ │ └── vertx │ │ └── tests │ │ └── db2client │ │ ├── tck │ │ ├── DB2PreparedQueryPooledTest.java │ │ ├── DB2CollectorTest.java │ │ └── DB2PreparedQueryTest.java │ │ ├── junit │ │ └── TestUtil.java │ │ ├── DB2QueriesTest.java │ │ ├── DB2RowTest.java │ │ └── DB2PingTest.java └── scripts │ └── db2.sh ├── vertx-mssql-client ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.vertx.sqlclient.spi.Driver │ │ └── java │ │ │ ├── io │ │ │ └── vertx │ │ │ │ └── mssqlclient │ │ │ │ ├── package-info.java │ │ │ │ └── impl │ │ │ │ ├── codec │ │ │ │ ├── EncryptionLevel.java │ │ │ │ ├── CloseConnectionMSSQLCommandMessage.java │ │ │ │ ├── MessageStatus.java │ │ │ │ ├── Done.java │ │ │ │ ├── MSSQLPreparedStatement.java │ │ │ │ ├── ExtendedQueryMSSQLCommandMessage.java │ │ │ │ ├── PrepareStatementMSSQLMessage.java │ │ │ │ ├── MessageType.java │ │ │ │ └── TdsPacket.java │ │ │ │ ├── command │ │ │ │ ├── PreLoginCommand.java │ │ │ │ └── PreLoginResponse.java │ │ │ │ ├── utils │ │ │ │ └── Utils.java │ │ │ │ └── MSSQLDatabaseMetadata.java │ │ │ └── module-info.java │ └── test │ │ ├── resources │ │ ├── mssql-tls.conf │ │ ├── mssql-force-encryption.conf │ │ ├── ssl.txt │ │ └── mssql.pem │ │ └── java │ │ ├── io │ │ └── vertx │ │ │ └── tests │ │ │ └── mssqlclient │ │ │ ├── data │ │ │ ├── MSSQLNotNullableDataTypeTestBase.java │ │ │ ├── MSSQLQueryNotNullableDataTypeTest.java │ │ │ └── MSSQLQueryNullableDataTypeTest.java │ │ │ ├── MSSQLTestBase.java │ │ │ ├── tck │ │ │ ├── MSSQLBatchTest.java │ │ │ ├── MSSQLCollectorTest.java │ │ │ ├── MSSQLBatchPooledTest.java │ │ │ ├── MSSQLPreparedQueryPooledTest.java │ │ │ └── MSSQLPreparedBatchTest.java │ │ │ └── impl │ │ │ └── MSSQLRowTest.java │ │ └── module-info.java └── docker │ └── initdb.sh ├── vertx-mysql-client ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.vertx.sqlclient.spi.Driver │ │ ├── asciidoc │ │ │ └── cursor_warning.adoc │ │ └── java │ │ │ ├── io │ │ │ └── vertx │ │ │ │ └── mysqlclient │ │ │ │ ├── impl │ │ │ │ ├── codec │ │ │ │ │ ├── ClearCachedStatementsEvent.java │ │ │ │ │ └── MySQLPacketDecoder.java │ │ │ │ ├── datatype │ │ │ │ │ └── DataFormat.java │ │ │ │ ├── command │ │ │ │ │ ├── PingCommand.java │ │ │ │ │ ├── DebugCommand.java │ │ │ │ │ ├── StatisticsCommand.java │ │ │ │ │ ├── ResetConnectionCommand.java │ │ │ │ │ ├── InitDbCommand.java │ │ │ │ │ ├── SetOptionCommand.java │ │ │ │ │ └── ChangeUserCommand.java │ │ │ │ ├── MySQLParamDesc.java │ │ │ │ └── MySQLPoolOptions.java │ │ │ │ ├── package-info.java │ │ │ │ ├── MySQLSetOption.java │ │ │ │ ├── data │ │ │ │ └── spatial │ │ │ │ │ ├── Geometry.java │ │ │ │ │ ├── Point.java │ │ │ │ │ └── LineString.java │ │ │ │ ├── MySQLClient.java │ │ │ │ └── MySQLException.java │ │ │ └── module-info.java │ └── test │ │ ├── java │ │ ├── module-info.java │ │ └── io │ │ │ └── vertx │ │ │ └── tests │ │ │ └── mysqlclient │ │ │ ├── MySQLBatchInsertExceptionTest.java │ │ │ ├── tck │ │ │ ├── MySQLPreparedQueryPooledTest.java │ │ │ ├── MySQLCollectorTest.java │ │ │ ├── MySQLSimpleQueryPooledTest.java │ │ │ ├── ProxySQLPreparedBatchTest.java │ │ │ ├── MySQLPreparedBatchTest.java │ │ │ └── MySQLNullValueEncodeTest.java │ │ │ ├── MySQLPipelinedBatchInsertExceptionTest.java │ │ │ ├── data │ │ │ └── SpatialTextCodecTest.java │ │ │ └── ProxySQLBatchInsertExceptionTest.java │ │ └── resources │ │ └── tls │ │ ├── files │ │ ├── public_key.pem │ │ ├── ca.pem │ │ ├── client-cert.pem │ │ └── server-cert.pem │ │ └── conf │ │ └── my.cnf └── docker │ └── mysql │ └── README.md ├── vertx-oracle-client └── src │ ├── main │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── io.vertx.sqlclient.spi.Driver │ └── java │ │ ├── io │ │ └── vertx │ │ │ └── oracleclient │ │ │ ├── package-info.java │ │ │ ├── OracleException.java │ │ │ ├── impl │ │ │ ├── commands │ │ │ │ ├── OracleCloseStatementCommand.java │ │ │ │ └── OracleCloseCursorCommand.java │ │ │ └── FailureUtil.java │ │ │ ├── ServerMode.java │ │ │ └── OracleClient.java │ │ └── module-info.java │ └── test │ └── java │ ├── module-info.java │ └── tests │ └── oracleclient │ ├── OracleGeneratedKeysPooledTest.java │ ├── OracleGeneratedKeysTest.java │ └── tck │ ├── OracleSimpleQueryTest.java │ ├── OracleDriverTest.java │ └── OracleNullValueEncodeTest.java ├── vertx-sql-client └── src │ ├── main │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── io.vertx.core.spi.VertxServiceProvider │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── sqlclient │ │ │ ├── internal │ │ │ ├── RowInternal.java │ │ │ └── SqlConnectionInternal.java │ │ │ ├── impl │ │ │ ├── pool │ │ │ │ └── ConnectionWrapper.java │ │ │ ├── TransactionPropagationLocal.java │ │ │ ├── SqlClientInternal.java │ │ │ ├── tracing │ │ │ │ └── QueryRequest.java │ │ │ ├── SqlResultImpl.java │ │ │ ├── RowStreamInternal.java │ │ │ ├── SingletonSupplier.java │ │ │ └── ErrorMessageFactory.java │ │ │ ├── spi │ │ │ ├── protocol │ │ │ │ ├── CompositeCommand.java │ │ │ │ ├── package-info.java │ │ │ │ ├── CommandBase.java │ │ │ │ ├── CloseConnectionCommand.java │ │ │ │ ├── TxCommand.java │ │ │ │ ├── CloseStatementCommand.java │ │ │ │ └── CommandScheduler.java │ │ │ ├── connection │ │ │ │ ├── package-info.java │ │ │ │ ├── ConnectionContext.java │ │ │ │ └── ConnectionFactory.java │ │ │ └── DatabaseMetadata.java │ │ │ ├── package-info.java │ │ │ ├── RowIterator.java │ │ │ ├── ClosedConnectionException.java │ │ │ ├── desc │ │ │ ├── RowDescriptor.java │ │ │ └── ColumnDescriptor.java │ │ │ └── TransactionRollbackException.java │ └── asciidoc │ │ ├── tracing.adoc │ │ ├── pool_sharing.adoc │ │ ├── cursor.adoc │ │ ├── pool_config.adoc │ │ └── connections.adoc │ └── test │ └── java │ ├── module-info.java │ └── io │ └── vertx │ └── tests │ └── sqlclient │ ├── tck │ └── Connector.java │ └── ArrayTupleTest.java ├── vertx-sql-client-templates └── src │ ├── test │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── io.vertx.codegen.GeneratorLoader │ └── java │ │ ├── io │ │ └── vertx │ │ │ └── tests │ │ │ └── sqlclient │ │ │ └── templates │ │ │ ├── LocalDateTimePojo.java │ │ │ ├── wrappers │ │ │ ├── LongWrapper.java │ │ │ ├── FloatWrapper.java │ │ │ ├── ShortWrapper.java │ │ │ ├── DoubleWrapper.java │ │ │ ├── StringWrapper.java │ │ │ ├── BooleanWrapper.java │ │ │ ├── IntegerWrapper.java │ │ │ ├── JsonArrayWrapper.java │ │ │ ├── JsonObjectWrapper.java │ │ │ └── WrapperBase.java │ │ │ ├── World.java │ │ │ ├── LocalDateTimeDataObject.java │ │ │ ├── JsonObjectDataObject.java │ │ │ ├── MySQLDataObject.java │ │ │ ├── package-info.java │ │ │ └── UserDataObject.java │ │ └── module-info.java │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── io.vertx.codegen.processor.GeneratorLoader │ └── java │ ├── module-info.java │ └── io │ └── vertx │ └── sqlclient │ └── templates │ ├── generator │ └── MapperGenLoader.java │ ├── annotations │ ├── Column.java │ ├── TemplateParameter.java │ ├── RowMapped.java │ └── ParametersMapped.java │ ├── package-info.java │ └── RowMapper.java ├── .editorconfig ├── .github └── workflows │ ├── ci-5.x.yml │ ├── ci-5.x-stable.yml │ └── ci.yml └── .gitignore /vertx-pg-client/src/main/asciidoc/override.adoc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/main/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vertx-db2-client/.gitignore: -------------------------------------------------------------------------------- 1 | src/reference/ 2 | src/main/examples/Scratch.java 3 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/resources/META-INF/services/io.vertx.sqlclient.spi.Driver: -------------------------------------------------------------------------------- 1 | io.vertx.pgclient.spi.PgDriver -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/pgBouncer/userlist.txt: -------------------------------------------------------------------------------- 1 | "postgres" "md53175bce1d3201d16594cebf9d7eb3f9d" 2 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/resources/META-INF/services/io.vertx.sqlclient.spi.Driver: -------------------------------------------------------------------------------- 1 | io.vertx.db2client.spi.DB2Driver -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/resources/META-INF/services/io.vertx.sqlclient.spi.Driver: -------------------------------------------------------------------------------- 1 | io.vertx.mssqlclient.spi.MSSQLDriver -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/resources/META-INF/services/io.vertx.sqlclient.spi.Driver: -------------------------------------------------------------------------------- 1 | io.vertx.mysqlclient.spi.MySQLDriver -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/resources/META-INF/services/io.vertx.sqlclient.spi.Driver: -------------------------------------------------------------------------------- 1 | io.vertx.oracleclient.spi.OracleDriver 2 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/resources/META-INF/services/io.vertx.core.spi.VertxServiceProvider: -------------------------------------------------------------------------------- 1 | io.vertx.sqlclient.impl.TransactionPropagationLocal 2 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/tls/force_ssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # force ssl 4 | cp /tmp/pg_hba.conf /var/lib/postgresql/data/pg_hba.conf 5 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/resources/META-INF/services/io.vertx.codegen.GeneratorLoader: -------------------------------------------------------------------------------- 1 | io.vertx.sqlclient.templates.generator.MapperGenLoader 2 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/resources/mssql-tls.conf: -------------------------------------------------------------------------------- 1 | [network] 2 | tlscert = /etc/ssl/certs/mssql.pem 3 | tlskey = /etc/ssl/certs/mssql.key 4 | tlsprotocols = 1.2 5 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/OutboundMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | public class OutboundMessage { 4 | } 5 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/resources/META-INF/services/io.vertx.codegen.processor.GeneratorLoader: -------------------------------------------------------------------------------- 1 | io.vertx.sqlclient.templates.generator.MapperGenLoader 2 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/tls/db2-keystore.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-vertx/vertx-sql-client/HEAD/vertx-db2-client/src/test/resources/tls/db2-keystore.p12 -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/tls/server/server.kdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-vertx/vertx-sql-client/HEAD/vertx-db2-client/src/test/resources/tls/server/server.kdb -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/tls/server/server.sth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-vertx/vertx-sql-client/HEAD/vertx-db2-client/src/test/resources/tls/server/server.sth -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/resources/mssql-force-encryption.conf: -------------------------------------------------------------------------------- 1 | [network] 2 | tlscert = /etc/ssl/certs/mssql.pem 3 | tlskey = /etc/ssl/certs/mssql.key 4 | tlsprotocols = 1.2 5 | forceencryption = 1 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | trim_trailing_whitespace = true 8 | end_of_line = lf 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/ConnectionState.java: -------------------------------------------------------------------------------- 1 | package io.vertx.db2client.impl.codec; 2 | 3 | public enum ConnectionState { 4 | CONNECTING, AUTHENTICATING, CONNECTED, CONNECT_FAILED 5 | } 6 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/SyncMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class SyncMessage extends OutboundMessage { 4 | 5 | static final SyncMessage INSTANCE = new SyncMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/data/MSSQLNotNullableDataTypeTestBase.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.mssqlclient.data; 2 | 3 | public abstract class MSSQLNotNullableDataTypeTestBase extends MSSQLFullDataTypeTestBase { 4 | } 5 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ParseMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class ParseMessage extends OutboundMessage { 4 | 5 | static final ParseMessage INSTANCE = new ParseMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ExecuteMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class ExecuteMessage extends OutboundMessage { 4 | 5 | static final ExecuteMessage INSTANCE = new ExecuteMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/TerminateMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class TerminateMessage extends OutboundMessage { 4 | 5 | static final TerminateMessage INSTANCE = new TerminateMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-pg-client/docker/postgres_tc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM postgres 2 | ENV POSTGRES_DB postgres 3 | ENV POSTGRES_USER postgres 4 | ENV POSTGRES_PASSWORD postgres 5 | RUN apt-get update && apt-get install -y iproute 6 | COPY create-postgres.sql /docker-entrypoint-initdb.d/ 7 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ClosePortalMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class ClosePortalMessage extends OutboundMessage { 4 | 5 | static final ClosePortalMessage INSTANCE = new ClosePortalMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/LocalDateTimePojo.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | import java.time.LocalDateTime; 4 | 5 | public class LocalDateTimePojo { 6 | 7 | public LocalDateTime localDateTime; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/LongWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class LongWrapper extends WrapperBase { 4 | 5 | public LongWrapper(Long value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/FloatWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class FloatWrapper extends WrapperBase { 4 | 5 | public FloatWrapper(Float value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/ShortWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class ShortWrapper extends WrapperBase { 4 | 5 | public ShortWrapper(Short value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/DoubleWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class DoubleWrapper extends WrapperBase { 4 | 5 | public DoubleWrapper(Double value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/StringWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class StringWrapper extends WrapperBase { 4 | 5 | public StringWrapper(String value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/BooleanWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class BooleanWrapper extends WrapperBase { 4 | 5 | public BooleanWrapper(Boolean value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/IntegerWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | public class IntegerWrapper extends WrapperBase { 4 | 5 | public IntegerWrapper(Integer value) { 6 | super(value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ClosePreparedStatementMessage.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.codec; 2 | 3 | class ClosePreparedStatementMessage extends OutboundMessage { 4 | 5 | static final ClosePreparedStatementMessage INSTANCE = new ClosePreparedStatementMessage(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.codec { 2 | 3 | requires io.vertx.core; 4 | requires io.vertx.core.logging; 5 | requires io.vertx.sql.client; 6 | requires io.vertx.sql.client.codec; 7 | requires io.vertx.testing.unit; 8 | requires java.sql; 9 | requires junit; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/context/EventLoopContextTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.context; 2 | 3 | import io.vertx.core.Context; 4 | 5 | public class EventLoopContextTest extends ContextTest { 6 | 7 | @Override 8 | protected Context createContext() { 9 | return vertx.getOrCreateContext(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/JsonArrayWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | import io.vertx.core.json.JsonArray; 4 | 5 | public class JsonArrayWrapper extends WrapperBase { 6 | 7 | public JsonArrayWrapper(JsonArray value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/JsonObjectWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | 5 | public class JsonObjectWrapper extends WrapperBase { 6 | 7 | public JsonObjectWrapper(JsonObject value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout 2 | 3 | log4j.appender=org.apache.log4j.ConsoleAppender 4 | log4j.appender.layout=org.apache.log4j.PatternLayout 5 | 6 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%r %p %c %x - %m%n -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/vertx-default-jul-logging.properties: -------------------------------------------------------------------------------- 1 | handlers=java.util.logging.ConsoleHandler 2 | java.util.logging.ConsoleHandler.level=FINEST 3 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 4 | java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %4$s %2$-55.55s %5$s%6$s%n 5 | 6 | .level=INFO 7 | io.vertx.db2client.level=FINEST -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.oracle { 2 | 3 | requires io.vertx.core; 4 | requires io.vertx.sql.client; 5 | requires io.vertx.sql.client.oracle; 6 | requires io.vertx.tests.sql.client; 7 | requires java.sql; 8 | requires io.vertx.testing.unit; 9 | requires junit; 10 | requires testcontainers; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/pgBouncer/pgbouncer.ini: -------------------------------------------------------------------------------- 1 | [databases] 2 | * = host=host.testcontainers.internal port=5432 3 | 4 | [pgbouncer] 5 | listen_addr = 0.0.0.0 6 | listen_port = 6432 7 | auth_type = md5 8 | auth_file = /etc/pgbouncer/userlist.txt 9 | pool_mode = transaction 10 | max_client_conn = 2 11 | admin_users = postgres 12 | ignore_startup_parameters = extra_float_digits 13 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/pgBouncer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:43 2 | RUN dnf -y update \ 3 | && dnf -y install pgbouncer \ 4 | && dnf clean all 5 | RUN mkdir -p /var/run/pgbouncer /var/log/pgbouncer \ 6 | && chown -R pgbouncer:pgbouncer /var/run/pgbouncer /var/log/pgbouncer /etc/pgbouncer 7 | EXPOSE 6432 8 | USER pgbouncer 9 | CMD ["pgbouncer", "/etc/pgbouncer/pgbouncer.ini"] 10 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/World.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | public class World { 4 | 5 | public World() { 6 | } 7 | 8 | public World(int id, int randomnumber) { 9 | this.id = id; 10 | this.randomnumber = randomnumber; 11 | } 12 | 13 | public int id; 14 | public int randomnumber; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/resources/ssl.txt: -------------------------------------------------------------------------------- 1 | For reference, browse to: 2 | https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-docker-container-security?view=sql-server-ver15#encrypting-connections-to-sql-server-linux-containers 3 | 4 | Certificate and key created with the following command: 5 | openssl req -x509 -nodes -newkey rsa:2048 -subj '/CN=sql1' -keyout mssql.key -out mssql.pem -days 36500 6 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.mssql { 2 | 3 | requires io.vertx.core; 4 | requires io.vertx.sql.client; 5 | requires io.vertx.sql.client.mssql; 6 | requires io.vertx.tests.sql.client; 7 | requires java.sql; 8 | requires io.vertx.testing.unit; 9 | requires junit; 10 | requires testcontainers; 11 | requires hamcrest.core; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/ci-5.x.yml: -------------------------------------------------------------------------------- 1 | name: vertx-sql-client (5.x) 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | branches: 8 | - master 9 | schedule: 10 | - cron: '0 5 * * *' 11 | jobs: 12 | CI-CD: 13 | uses: ./.github/workflows/ci-matrix-5.x.yml 14 | secrets: inherit 15 | with: 16 | branch: ${{ github.event.pull_request.head.sha || github.ref_name }} 17 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/context/WorkerContextTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.context; 2 | 3 | 4 | import io.vertx.core.Context; 5 | import io.vertx.core.internal.VertxInternal; 6 | 7 | public class WorkerContextTest extends ContextTest { 8 | 9 | @Override 10 | protected Context createContext() { 11 | return ((VertxInternal)vertx).createWorkerContext(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vertx-sql-client/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client { 2 | 3 | requires io.vertx.core; 4 | requires io.vertx.core.logging; 5 | requires io.vertx.sql.client; 6 | requires io.vertx.testing.unit; 7 | requires java.sql; 8 | requires junit; 9 | 10 | uses io.vertx.sqlclient.spi.Driver; 11 | 12 | exports io.vertx.tests.sqlclient; 13 | exports io.vertx.tests.sqlclient.tck; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mssql-client/docker/initdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | SERVER="$1" 6 | PASSWORD="$2" 7 | SQL_FILE="$3" 8 | 9 | until /opt/mssql-tools18/bin/sqlcmd -l 1 -S $SERVER -U SA -P $PASSWORD -C -No -q "SELECT 1"; do 10 | >&2 echo "MSSQL is unavailable - sleeping" 11 | sleep 1 12 | done 13 | 14 | >&2 echo "MSSQL is up - executing command" 15 | /opt/mssql-tools18/bin/sqlcmd -S $SERVER -U SA -P $PASSWORD -i $SQL_FILE -C -No 16 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/context/DuplicateContextTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.context; 2 | 3 | 4 | import io.vertx.core.Context; 5 | import io.vertx.core.internal.ContextInternal; 6 | 7 | public class DuplicateContextTest extends ContextTest { 8 | 9 | @Override 10 | protected Context createContext() { 11 | return ((ContextInternal)vertx.getOrCreateContext()).duplicate(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/tls/ssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Borrowed from https://github.com/muccg/docker-postgres-ssl/blob/master/9.6/docker-entrypoint-initdb.d/devssl.sh 4 | 5 | cp /server.crt "${PGDATA}"/server.crt 6 | cp /server.key "${PGDATA}"/server.key 7 | chmod og-rwx "${PGDATA}"/server.key 8 | chown -R postgres:postgres "${PGDATA}" 9 | 10 | # turn on ssl 11 | sed -ri "s/^#?(ssl\s*=\s*)\S+/\1'on'/" "$PGDATA/postgresql.conf" 12 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/asciidoc/cursor_warning.adoc: -------------------------------------------------------------------------------- 1 | [CAUTION] 2 | ==== 3 | At the time of writing, you cannot use the following features if you connect to your database through ProxySQL. 4 | If you try, you will see this error message: 5 | 6 | ---- 7 | RECEIVED AN UNKNOWN COMMAND: 28 -- PLEASE REPORT A BUG 8 | ---- 9 | 10 | This is because the proxy does not handle a type of command (`COM_STMT_FETCH`) that is required to fetch rows from a cursor. 11 | ==== 12 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/codec/ClearCachedStatementsEvent.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mysqlclient.impl.codec; 2 | 3 | /** 4 | * An event that signals all cached statements must be cleared from the cache. 5 | */ 6 | public class ClearCachedStatementsEvent { 7 | 8 | public static final ClearCachedStatementsEvent INSTANCE = new ClearCachedStatementsEvent(); 9 | 10 | private ClearCachedStatementsEvent() { 11 | // Singleton 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.codec { 2 | 3 | requires io.netty.common; 4 | requires io.netty.buffer; 5 | requires io.netty.codec; 6 | requires io.netty.transport; 7 | 8 | requires io.vertx.core; 9 | requires io.vertx.core.logging; 10 | 11 | requires io.vertx.sql.client; 12 | 13 | exports io.vertx.sqlclient.codec; 14 | exports io.vertx.sqlclient.codec.impl to io.vertx.tests.sql.client.codec; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.mysql { 2 | 3 | requires io.netty.common; 4 | requires io.netty.buffer; 5 | requires io.vertx.core; 6 | requires io.vertx.sql.client; 7 | requires io.vertx.sql.client.mysql; 8 | requires io.vertx.tests.sql.client; 9 | requires java.sql; 10 | requires io.vertx.testing.unit; 11 | requires junit; 12 | requires testcontainers; 13 | requires com.github.dockerjava.api; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-pg-client/docker/postgres_tc/README.md: -------------------------------------------------------------------------------- 1 | ## Postgres docker file for testing with tc 2 | 3 | Build container with tc installed 4 | 5 | ``` 6 | > docker build -t test/postgres_tc postgres 7 | ``` 8 | 9 | Running the container 10 | 11 | ``` 12 | > docker run --rm --name test-postgres_tc -p 5432:5432 --cap-add=NET_ADMIN test/postgres_tc 13 | ``` 14 | 15 | Add one 1 ms latency to eth0 16 | 17 | ``` 18 | > docker exec -it test-postgres_tc tc qdisc add dev eth0 root netem delay 1ms 19 | ``` 20 | -------------------------------------------------------------------------------- /.github/workflows/ci-5.x-stable.yml: -------------------------------------------------------------------------------- 1 | name: vertx-sql-client (5.x-stable) 2 | on: 3 | push: 4 | branches: 5 | - '5.[0-9]+' 6 | pull_request: 7 | branches: 8 | - '5.[0-9]+' 9 | schedule: 10 | - cron: '0 6 * * *' 11 | jobs: 12 | CI-CD: 13 | uses: ./.github/workflows/ci-matrix-5.x.yml 14 | secrets: inherit 15 | with: 16 | branch: ${{ github.event_name == 'schedule' && vars.VERTX_5_STABLE_BRANCH || github.event.pull_request.head.sha || github.ref_name }} 17 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgPreparedQueryPooledTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.tck; 2 | 3 | import io.vertx.ext.unit.junit.VertxUnitRunner; 4 | import org.junit.runner.RunWith; 5 | 6 | @RunWith(VertxUnitRunner.class) 7 | public class PgPreparedQueryPooledTest extends PgPreparedQueryTestBase { 8 | @Override 9 | protected void initConnector() { 10 | options = rule.options(); 11 | connector = ClientConfig.POOLED.connect(vertx, options); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/main/java/io/vertx/sqlclient/codec/InvalidCachedStatementEvent.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.codec; 2 | 3 | /** 4 | * An event signals when a cached prepared statement is invalid and needs to be evicted from the cache. 5 | */ 6 | public class InvalidCachedStatementEvent { 7 | 8 | private final String sql; 9 | 10 | public InvalidCachedStatementEvent(String sql) { 11 | this.sql = sql; 12 | } 13 | 14 | public String sql() { 15 | return sql; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/tck/DB2PreparedQueryPooledTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.db2client.tck; 2 | 3 | import org.junit.runner.RunWith; 4 | 5 | import io.vertx.ext.unit.junit.VertxUnitRunner; 6 | 7 | @RunWith(VertxUnitRunner.class) 8 | public class DB2PreparedQueryPooledTest extends DB2PreparedQueryTestBase { 9 | @Override 10 | protected void initConnector() { 11 | options = rule.options(); 12 | connector = ClientConfig.POOLED.connect(vertx, options); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/resources/tls/files/public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3yvG5s0qrV7jxVlp0sMj 3 | xP0a6BuLKCMjb0o88hDsJ3xz7PpHNKazuEAfPxiRFVAV3edqfSiXoQw+lJf4haEG 4 | HQe12Nfhs+UhcAeTKXRlZP/JNmI+BGoBduQ1rCId9bKYbXn4pvyS/a1ft7SwFkhx 5 | aogCur7iIB0WUWvwkQ0fEj/Mlhw93lLVyx7hcGFq4FOAKFYr3A0xrHP1IdgnD8QZ 6 | 0fUbgGLWWLOossKrbUP5HWko1ghLPIbfmU6o890oj1ZWQewj1Rs9Er92/UDj/JXx 7 | 7ha1P+ZOgPBlV037KDQMS6cUh9vTablEHsMLhDZanymXzzjBkL+wH/b9cdL16LkQ 8 | 5QIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.pg { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.transport; 5 | requires io.vertx.core; 6 | requires io.vertx.sql.client; 7 | requires io.vertx.sql.client.pg; 8 | requires io.vertx.tests.sql.client; 9 | requires java.sql; 10 | requires jmh.core; 11 | requires io.vertx.testing.unit; 12 | requires junit; 13 | requires testcontainers; 14 | requires static org.slf4j; 15 | requires org.apache.commons.compress; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | open module io.vertx.tests.sql.client.templates { 2 | requires com.fasterxml.jackson.databind; 3 | requires com.fasterxml.jackson.datatype.jsr310; 4 | requires static io.vertx.codegen.api; 5 | requires io.vertx.core; 6 | requires io.vertx.sql.client; 7 | requires io.vertx.sql.client.mysql; 8 | requires io.vertx.sql.client.pg; 9 | requires io.vertx.sql.client.templates; 10 | requires io.vertx.testing.unit; 11 | requires junit; 12 | requires testcontainers; 13 | } 14 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/internal/RowInternal.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.internal; 2 | 3 | import io.vertx.sqlclient.Row; 4 | 5 | /** 6 | * Row internal API 7 | */ 8 | public interface RowInternal extends Row { 9 | 10 | /** 11 | * Try to recycle the row, this shall be called by the row decoder to check whether the row 12 | * instance can be reused. 13 | * 14 | * @return whether the row can be reused safely 15 | */ 16 | default boolean tryRecycle() { 17 | return false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | jitwatch.out 2 | jekyll/apidocs 3 | jekyll/yardoc 4 | jekyll/guide 5 | jekyll/.* 6 | jekyll/_site 7 | jekyll/jsdoc 8 | *.log 9 | .vertx 10 | .DS_Store 11 | .gradle 12 | .idea 13 | .classpath 14 | .project 15 | .settings 16 | .yardoc 17 | .yardopts 18 | build 19 | target 20 | out 21 | *.iml 22 | *.ipr 23 | *.iws 24 | *.jfr 25 | test-output 26 | Scratch.java 27 | ScratchTest.java 28 | test-results 29 | test-tmp 30 | *.class 31 | ScratchPad.java 32 | src/main/resources/ext-js/*.js 33 | src/main/java/io/vertx/java/**/*.java 34 | *.swp 35 | generated/ 36 | bin/ 37 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/impl/MD5AuthenticationTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.impl; 2 | 3 | import io.vertx.pgclient.impl.util.MD5Authentication; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | import java.nio.charset.StandardCharsets; 8 | 9 | public class MD5AuthenticationTest { 10 | 11 | @Test 12 | public void encodeTest() { 13 | Assert.assertEquals( 14 | "md54cd35160716308e3e571bbba12bb7591", 15 | MD5Authentication.encode("scott", "tiger", "salt'n'pepper".getBytes(StandardCharsets.UTF_8))); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.templates { 2 | 3 | requires static io.vertx.codegen.processor; 4 | requires static io.vertx.codegen.json; 5 | requires static io.vertx.codegen.api; 6 | requires static java.compiler; 7 | requires static io.vertx.docgen; 8 | 9 | requires io.vertx.sql.client; 10 | requires io.vertx.core; 11 | 12 | exports io.vertx.sqlclient.templates; 13 | exports io.vertx.sqlclient.templates.annotations; 14 | 15 | exports io.vertx.sqlclient.templates.impl to io.vertx.tests.sql.client.templates; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionWrapper.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.impl.pool; 2 | 3 | import io.vertx.core.internal.ContextInternal; 4 | import io.vertx.sqlclient.SqlConnectOptions; 5 | import io.vertx.sqlclient.spi.connection.Connection; 6 | import io.vertx.sqlclient.internal.SqlConnectionInternal; 7 | import io.vertx.sqlclient.spi.connection.ConnectionFactory; 8 | 9 | public interface ConnectionWrapper { 10 | 11 | SqlConnectionInternal wrap(ContextInternal context, ConnectionFactory factory, Connection conn); 12 | } 13 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/TransactionPropagationLocal.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.impl; 2 | 3 | import io.vertx.core.internal.VertxBootstrap; 4 | import io.vertx.core.spi.VertxServiceProvider; 5 | import io.vertx.core.spi.context.storage.ContextLocal; 6 | import io.vertx.sqlclient.SqlConnection; 7 | 8 | public class TransactionPropagationLocal implements VertxServiceProvider { 9 | 10 | public static final ContextLocal KEY = ContextLocal.registerLocal(SqlConnection.class); 11 | 12 | @Override 13 | public void init(VertxBootstrap builder) { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/resources/tls/conf/my.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | port=3306 3 | 4 | max_allowed_packet=33554432 5 | max_prepared_stmt_count=1024 6 | character-set-server=utf8mb4 7 | collation-server=utf8mb4_general_ci 8 | local_infile=ON 9 | 10 | #require_secure_transport=ON 11 | ssl-ca=/etc/mysql/tls/ca.pem 12 | ssl-cert=/etc/mysql/tls/server-cert.pem 13 | ssl-key=/etc/mysql/tls/server-key.pem 14 | 15 | # not useful for TLS testing and not supported by MySQL 5.6 as well 16 | #caching-sha2-password-public-key-path=/etc/mysql/tls/public_key.pem 17 | #caching-sha2-password-private-key-path=/etc/mysql/tls/private_key.pem 18 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/generator/MapperGenLoader.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.templates.generator; 2 | 3 | import io.vertx.codegen.processor.Generator; 4 | import io.vertx.codegen.processor.GeneratorLoader; 5 | 6 | import javax.annotation.processing.ProcessingEnvironment; 7 | import java.util.stream.Stream; 8 | 9 | public class MapperGenLoader implements GeneratorLoader { 10 | 11 | @Override 12 | public Stream> loadGenerators(ProcessingEnvironment processingEnv) { 13 | return Stream.of(new RowMapperGen(), new ParametersMapperGen()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/resources/tls/db2_tls_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "BEGIN SSH SETUP" 4 | export PATH=/opt/ibm/db2/V11.5/bin/:$PATH 5 | 6 | su - vertx -c 'db2 update dbm cfg using DIAGLEVEL 2' 7 | su - vertx -c 'db2 update dbm cfg using SSL_SVR_KEYDB /certs/server.kdb' 8 | su - vertx -c 'db2 update dbm cfg using SSL_SVR_STASH /certs/server.sth' 9 | su - vertx -c 'db2 update dbm cfg using SSL_SVR_LABEL mylabel' 10 | su - vertx -c 'db2 update dbm cfg using ssl_svcename 50001' 11 | su - vertx -c 'db2set -i vertx DB2COMM=SSL,TCPIP' 12 | su - vertx -c 'db2stop' 13 | su - vertx -c 'db2start' 14 | 15 | echo "VERTX SSH SETUP DONE" -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/datatype/DataFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.datatype; 13 | 14 | public enum DataFormat { 15 | TEXT, BINARY 16 | } 17 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/LocalDateTimeDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.sqlclient.templates.annotations.RowMapped; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @DataObject 9 | @RowMapped 10 | public class LocalDateTimeDataObject { 11 | 12 | private LocalDateTime localDateTime; 13 | 14 | public LocalDateTime getLocalDateTime() { 15 | return localDateTime; 16 | } 17 | 18 | public void setLocalDateTime(LocalDateTime localDateTime) { 19 | this.localDateTime = localDateTime; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/annotations/Column.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.templates.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotate a Vert.x data object property for custom configuration when it is mapped to a column. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.METHOD, ElementType.FIELD}) 13 | public @interface Column { 14 | 15 | /** 16 | * @return the column name 17 | */ 18 | String name() default ""; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlClientInternal.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.impl; 2 | 3 | import io.vertx.core.Handler; 4 | import io.vertx.sqlclient.SqlClient; 5 | import io.vertx.sqlclient.spi.Driver; 6 | 7 | public interface SqlClientInternal extends SqlClient { 8 | 9 | /** 10 | * @return the client driver 11 | */ 12 | Driver driver(); 13 | 14 | /** 15 | * Experimental API not yet exposed. 16 | * 17 | *

Execute the code {@code block} with a client that defers the flush of queries after its execution. 18 | * 19 | * @param block the block to execute 20 | */ 21 | void group(Handler block); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | @ModuleGen(name = "vertx-oracle-client", groupPackage = "io.vertx") 12 | package io.vertx.oracleclient; 13 | 14 | import io.vertx.codegen.annotations.ModuleGen; 15 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | @ModuleGen(name = "vertx-mssql-client", groupPackage = "io.vertx") 13 | package io.vertx.mssqlclient; 14 | 15 | import io.vertx.codegen.annotations.ModuleGen; 16 | -------------------------------------------------------------------------------- /vertx-pg-client/docker/postgres/README.md: -------------------------------------------------------------------------------- 1 | ## Postgres containers for testing 2 | 3 | There will be 2 Postgres containers for testing, one with SSL enabled is for `TLSTest` and the other one with SSL disabled is for all other tests. 4 | 5 | ### Configure the containers 6 | 7 | Modify the content in the `docker compose.yml` 8 | 9 | ### Run the containers 10 | 11 | ```shell 12 | docker compose up --build -V 13 | ``` 14 | 15 | ### Run tests 16 | 17 | ```shell 18 | mvn test -Dconnection.uri=postgres://postgres:postgres@localhost:5432/postgres -Dtls.connection.uri=postgres://postgres:postgres@localhost:5433/postgres -Dunix.socket.directory=/var/run/postgresql -Dunix.socket.port=5432 19 | ``` 20 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgCollectorTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.tck; 2 | 3 | import org.junit.ClassRule; 4 | import org.junit.runner.RunWith; 5 | 6 | import io.vertx.ext.unit.junit.VertxUnitRunner; 7 | import io.vertx.tests.pgclient.junit.ContainerPgRule; 8 | import io.vertx.tests.sqlclient.tck.CollectorTestBase; 9 | 10 | @RunWith(VertxUnitRunner.class) 11 | public class PgCollectorTest extends CollectorTestBase { 12 | @ClassRule 13 | public static ContainerPgRule rule = new ContainerPgRule(); 14 | 15 | @Override 16 | protected void initConnector() { 17 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/tracing/QueryRequest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.impl.tracing; 2 | 3 | import io.vertx.sqlclient.Tuple; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * A traceable query. 9 | */ 10 | public class QueryRequest { 11 | 12 | final QueryReporter tracer; 13 | final String sql; 14 | final List tuples; 15 | 16 | public QueryRequest(QueryReporter tracer, String sql, List tuples) { 17 | this.tracer = tracer; 18 | this.sql = sql; 19 | this.tuples = tuples; 20 | } 21 | 22 | public String sql() { 23 | return sql; 24 | } 25 | 26 | public List tuples() { 27 | return tuples; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/PingCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class PingCommand extends CommandBase { 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/DebugCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class DebugCommand extends CommandBase { 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/data/MSSQLQueryNotNullableDataTypeTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.mssqlclient.data; 2 | 3 | import io.vertx.ext.unit.TestContext; 4 | import io.vertx.ext.unit.junit.VertxUnitRunner; 5 | import io.vertx.sqlclient.Row; 6 | import org.junit.runner.RunWith; 7 | 8 | import java.util.function.Consumer; 9 | 10 | @RunWith(VertxUnitRunner.class) 11 | public class MSSQLQueryNotNullableDataTypeTest extends MSSQLNotNullableDataTypeTestBase { 12 | @Override 13 | protected void testDecodeValue(TestContext ctx, boolean isNull, String columnName, Consumer checker) { 14 | testQueryDecodeGeneric(ctx, "not_nullable_datatype", columnName, "1", checker); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/annotations/TemplateParameter.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.templates.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotate a Vert.x data object property for custom configuration when it is mapped to a template parameter. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.METHOD, ElementType.FIELD}) 13 | public @interface TemplateParameter { 14 | 15 | /** 16 | * @return the template parameter name 17 | */ 18 | String name() default ""; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/StatisticsCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class StatisticsCommand extends CommandBase { 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/ResetConnectionCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class ResetConnectionCommand extends CommandBase { 17 | } 18 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.db2 { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.codec; 5 | requires io.netty.common; 6 | requires io.netty.handler; 7 | requires io.netty.transport; 8 | requires io.vertx.sql.client; 9 | requires io.vertx.sql.client.codec; 10 | requires io.vertx.core; 11 | requires io.vertx.core.logging; 12 | requires java.sql; 13 | 14 | provides io.vertx.sqlclient.spi.Driver with io.vertx.db2client.spi.DB2Driver; // Un-tested 15 | 16 | exports io.vertx.db2client; 17 | exports io.vertx.db2client.spi; 18 | 19 | requires static io.vertx.docgen; 20 | requires static io.vertx.codegen.api; 21 | requires static io.vertx.codegen.json; 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vertx-db2-client/scripts/db2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Starting DB2 database with:" 3 | echo " user=db2user" 4 | echo " pass=db2pass" 5 | echo " dbname=vertx_db" 6 | echo " port=50000" 7 | echo "" 8 | echo "### DB will be usable when you see the following message ###" 9 | echo " (*) Setup has completed." 10 | echo "" 11 | echo "Press Ctrl+C to exit when you are finished" 12 | echo "" 13 | docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \ 14 | --name db2-vertx \ 15 | -e DBNAME=vertx_db \ 16 | -e DB2INSTANCE=db2user \ 17 | -e DB2INST1_PASSWORD=db2pass \ 18 | -e AUTOCONFIG=false \ 19 | -e ARCHIVE_LOGS=false \ 20 | -e LICENSE=accept \ 21 | -p 50000:50000 \ 22 | --privileged \ 23 | ibmcom/db2:11.5.0.0a 24 | 25 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/TxFailedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.pgclient.impl.codec; 12 | 13 | /** 14 | * Event to signal a transaction is failed. 15 | */ 16 | public class TxFailedEvent { 17 | 18 | public static final TxFailedEvent INSTANCE = new TxFailedEvent(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/CompositeCommand.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.spi.protocol; 2 | 3 | import io.vertx.core.Completable; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class CompositeCommand extends CommandBase { 9 | 10 | private final List> commands = new ArrayList<>(); 11 | private final List> handlers = new ArrayList<>(); 12 | 13 | public void add(CommandBase cmd, Completable handler) { 14 | commands.add(cmd); 15 | handlers.add(handler); 16 | } 17 | 18 | public List> commands() { 19 | return commands; 20 | } 21 | 22 | public List> handlers() { 23 | return handlers; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/connection/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2011-2025 Contributors to the Eclipse Foundation 4 | * 5 | * This program and the accompanying materials are made available under the 6 | * terms of the Eclipse Public License 2.0 which is available at 7 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 8 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 9 | * 10 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 11 | */ 12 | 13 | /** 14 | *

The Connection Service Provider Interface (SPI).

15 | * 16 | *

This SPI is the contract between a {@link io.vertx.sqlclient.spi.DriverBase} and a database backend.

17 | */ 18 | package io.vertx.sqlclient.spi.connection; 19 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/annotations/RowMapped.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.templates.annotations; 2 | 3 | import io.vertx.codegen.format.Case; 4 | import io.vertx.codegen.format.LowerCamelCase; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * Annotate a Vert.x data object to generate an SQL template row mapper. 13 | */ 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target({ElementType.TYPE}) 16 | public @interface RowMapped { 17 | 18 | /** 19 | * @return the row name formatter, default maps to lower camel case. 20 | */ 21 | Class formatter() default LowerCamelCase.class; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/MySQLBatchInsertExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import org.junit.runner.RunWith; 16 | 17 | @RunWith(VertxUnitRunner.class) 18 | public class MySQLBatchInsertExceptionTest extends MySQLBatchInsertExceptionTestBase { 19 | } 20 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.mssql { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.codec; 5 | requires io.netty.common; 6 | requires io.netty.handler; 7 | requires io.netty.transport; 8 | requires io.vertx.sql.client; 9 | requires io.vertx.sql.client.codec; 10 | requires io.vertx.core; 11 | requires io.vertx.core.logging; 12 | requires java.sql; 13 | 14 | provides io.vertx.sqlclient.spi.Driver with io.vertx.mssqlclient.spi.MSSQLDriver; 15 | 16 | exports io.vertx.mssqlclient; 17 | exports io.vertx.mssqlclient.spi; 18 | 19 | exports io.vertx.mssqlclient.impl to io.vertx.tests.sql.client.mssql; 20 | 21 | requires static io.vertx.docgen; 22 | requires static io.vertx.codegen.api; 23 | requires static io.vertx.codegen.json; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/wrappers/WrapperBase.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates.wrappers; 2 | 3 | import java.util.Objects; 4 | 5 | public abstract class WrapperBase { 6 | 7 | private final T value; 8 | 9 | public WrapperBase(T value) { 10 | this.value = value; 11 | } 12 | 13 | public T get() { 14 | return value; 15 | } 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | if (this == o) { 20 | return true; 21 | } 22 | if (o == null || getClass() != o.getClass()) { 23 | return false; 24 | } 25 | WrapperBase that = (WrapperBase) o; 26 | return Objects.equals(value, that.value); 27 | } 28 | 29 | @Override 30 | public int hashCode() { 31 | return value.hashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/annotations/ParametersMapped.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.templates.annotations; 2 | 3 | import io.vertx.codegen.format.Case; 4 | import io.vertx.codegen.format.LowerCamelCase; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * Annotate a Vert.x data object to generate an SQL template parameters mapper. 13 | */ 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target({ElementType.TYPE}) 16 | public @interface ParametersMapped { 17 | 18 | /** 19 | * @return the parameter name formatter, default maps to lower camel case. 20 | */ 21 | Class formatter() default LowerCamelCase.class; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2011-2025 Contributors to the Eclipse Foundation 4 | * 5 | * This program and the accompanying materials are made available under the 6 | * terms of the Eclipse Public License 2.0 which is available at 7 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 8 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 9 | * 10 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 11 | */ 12 | 13 | /** 14 | *

Defines the interaction protocol between the client and a database backend.

15 | * 16 | *

The client interacts with the backend with a set of commands modelling the interactions between a client 17 | * and a database.

18 | */ 19 | package io.vertx.sqlclient.spi.protocol; 20 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/connection/ConnectionContext.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.spi.connection; 2 | 3 | /** 4 | *

The connection context that handles connection interactions with the outer world, e.g. handling an event.

5 | * 6 | *

The connection context allows a connection to signal inner changes to its context (the client state machine).

7 | */ 8 | public interface ConnectionContext { 9 | 10 | /** 11 | * Signals a generic database event. 12 | * 13 | * @param event the event. 14 | */ 15 | void handleEvent(Object event); 16 | 17 | /** 18 | * Signals the connection is closed. 19 | */ 20 | void handleClosed(); 21 | 22 | /** 23 | * Signals a failure. 24 | * 25 | * @param failure the failure 26 | */ 27 | void handleException(Throwable failure); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/JsonObjectDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.json.JsonObject; 5 | 6 | import java.util.Objects; 7 | 8 | @DataObject 9 | public class JsonObjectDataObject { 10 | 11 | private final JsonObject json; 12 | 13 | public JsonObjectDataObject(JsonObject json) { 14 | Objects.requireNonNull(json); 15 | this.json = json; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object obj) { 20 | if (obj instanceof JsonObjectDataObject) { 21 | JsonObjectDataObject that = (JsonObjectDataObject) obj; 22 | return json.equals(that.json); 23 | } 24 | return false; 25 | } 26 | 27 | public JsonObject toJson() { 28 | return json; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mysql-client/docker/mysql/README.md: -------------------------------------------------------------------------------- 1 | ## MySQL containers for testing 2 | 3 | ### Configure the containers 4 | 5 | Modify the content in the `docker compose.yml` 6 | 7 | ### Run the containers 8 | 9 | ```shell 10 | docker compose up --build -V 11 | ``` 12 | 13 | ### TLS testing 14 | 15 | The SSL certificate and key files and RSA key-pair files can be generated with [mysql_ssl_rsa_setup](https://dev.mysql.com/doc/refman/8.0/en/mysql-ssl-rsa-setup.html) which is based on OpenSSL and could save a lot of work. 16 | 17 | The steps to generate these artifacts are quite easy: 18 | 19 | 1. make sure you have MySQL installed 20 | 2. mysql_ssl_rsa_setup --datadir=./ 21 | 22 | ### Run tests 23 | 24 | ```shell 25 | mvn test -Dconnection.uri=mysql://mysql:password@localhost:3306/testschema -Dtls.connection.uri=mysql://mysql:password@localhost:3307/testschema 26 | ``` 27 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/MySQLDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.json.JsonObject; 5 | import io.vertx.sqlclient.templates.annotations.ParametersMapped; 6 | import io.vertx.sqlclient.templates.annotations.RowMapped; 7 | 8 | import java.time.Duration; 9 | 10 | @DataObject 11 | @RowMapped 12 | @ParametersMapped 13 | public class MySQLDataObject { 14 | 15 | private Duration duration; 16 | 17 | public MySQLDataObject() { 18 | } 19 | 20 | public MySQLDataObject(JsonObject json) { 21 | } 22 | 23 | public Duration getDuration() { 24 | return duration; 25 | } 26 | 27 | public MySQLDataObject setDuration(Duration duration) { 28 | this.duration = duration; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | @ModuleGen(name = "vertx-db2-client", groupPackage = "io.vertx") 17 | package io.vertx.db2client; 18 | 19 | import io.vertx.codegen.annotations.ModuleGen; 20 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.oracle { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.codec; 5 | requires io.netty.common; 6 | requires io.netty.handler; 7 | requires io.netty.transport; 8 | requires com.oracle.database.jdbc; 9 | requires io.vertx.sql.client; 10 | requires io.vertx.core; 11 | requires io.vertx.core.logging; 12 | requires java.sql; 13 | 14 | provides io.vertx.sqlclient.spi.Driver with io.vertx.oracleclient.spi.OracleDriver; 15 | 16 | exports io.vertx.oracleclient; 17 | exports io.vertx.oracleclient.data; 18 | exports io.vertx.oracleclient.spi; 19 | 20 | exports io.vertx.oracleclient.impl to io.vertx.tests.sql.client.oracle; 21 | 22 | requires static io.vertx.docgen; 23 | requires static io.vertx.codegen.api; 24 | requires static io.vertx.codegen.json; 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | @ModuleGen(name = "vertx-pg-client", groupPackage = "io.vertx") 19 | package io.vertx.pgclient; 20 | 21 | import io.vertx.codegen.annotations.ModuleGen; 22 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | @ModuleGen(name = "vertx-sql-client", groupPackage = "io.vertx") 19 | package io.vertx.sqlclient; 20 | 21 | import io.vertx.codegen.annotations.ModuleGen; 22 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | @ModuleGen(name = "vertx-mysql-client", groupPackage = "io.vertx") 19 | package io.vertx.mysqlclient; 20 | 21 | import io.vertx.codegen.annotations.ModuleGen; 22 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/internal/SqlConnectionInternal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient.internal; 12 | 13 | import io.vertx.sqlclient.SqlConnection; 14 | import io.vertx.sqlclient.spi.connection.Connection; 15 | 16 | public interface SqlConnectionInternal extends SqlConnection { 17 | 18 | /** 19 | * @return the {@link Connection} out of this user-facing connection 20 | */ 21 | Connection unwrap(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/MySQLSetOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient; 13 | 14 | import io.vertx.codegen.annotations.VertxGen; 15 | import io.vertx.core.Handler; 16 | 17 | /** 18 | * MySQL set options which can be used by {@link MySQLConnection#setOption(MySQLSetOption)}. 19 | */ 20 | @VertxGen 21 | public enum MySQLSetOption { 22 | MYSQL_OPTION_MULTI_STATEMENTS_ON, MYSQL_OPTION_MULTI_STATEMENTS_OFF 23 | } 24 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/command/PingCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vertx.db2client.impl.command; 17 | 18 | import io.vertx.sqlclient.spi.protocol.CommandBase; 19 | 20 | public class PingCommand extends CommandBase { 21 | } 22 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/UUIDTypeSimpleCodecTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.data; 2 | 3 | import io.vertx.sqlclient.Row; 4 | import io.vertx.sqlclient.Tuple; 5 | import io.vertx.ext.unit.TestContext; 6 | import org.junit.Test; 7 | 8 | import java.util.UUID; 9 | 10 | public class UUIDTypeSimpleCodecTest extends SimpleQueryDataTypeCodecTestBase { 11 | @Test 12 | public void testUUID(TestContext ctx) { 13 | UUID expected = UUID.fromString("50867d3d-0098-4f61-bd31-9309ebf53475"); 14 | testDecodeGeneric(ctx, "50867d3d-0098-4f61-bd31-9309ebf53475", "UUID", "uuid", Tuple::getUUID, Row::getUUID, expected); 15 | } 16 | 17 | @Test 18 | public void testDecodeUUIDArray(TestContext ctx) { 19 | testDecodeGenericArray(ctx, "ARRAY ['6f790482-b5bd-438b-a8b7-4a0bed747011' :: UUID]", "UUID", Tuple::getArrayOfUUIDs, Row::getArrayOfUUIDs, uuid); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/asciidoc/tracing.adoc: -------------------------------------------------------------------------------- 1 | The SQL client can trace query execution when Vert.x has tracing enabled. 2 | 3 | The client reports the following _client_ spans: 4 | 5 | - `QueryMessage` operation name 6 | - tags 7 | - `db.system`: the database management system product 8 | - `db.user`: the database username 9 | - `db.instance`: the database instance 10 | - `db.statement`: the SQL query 11 | - `db.type`: _sql_ 12 | 13 | The default tracing policy is {@link io.vertx.core.tracing.TracingPolicy#PROPAGATE}, the client 14 | will only create a span when involved in an active trace. 15 | 16 | You can change the client policy with {@link io.vertx.sqlclient.SqlConnectOptions#setTracingPolicy}, 17 | e.g you can set {@link io.vertx.core.tracing.TracingPolicy#ALWAYS} to always report 18 | a span: 19 | 20 | [source,$lang] 21 | ---- 22 | {@link examples.SqlClientExamples#tracing01} 23 | ---- 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | workflow_call: 4 | inputs: 5 | branch: 6 | required: true 7 | type: string 8 | jdk: 9 | default: 8 10 | type: string 11 | os: 12 | default: ubuntu-latest 13 | type: string 14 | profile: 15 | type: string 16 | deploy: 17 | type: boolean 18 | jobs: 19 | Test: 20 | name: Run tests 21 | runs-on: ${{ inputs.os }} 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v2 25 | with: 26 | ref: ${{ inputs.branch }} 27 | - name: Install JDK 28 | uses: actions/setup-java@v2 29 | with: 30 | java-version: ${{ inputs.jdk }} 31 | distribution: temurin 32 | - name: Run tests 33 | run: mvn -s .github/maven-ci-settings.xml -q clean verify -B -DskipDefault -P ${{ inputs.profile }} 34 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/EncryptionLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | public class EncryptionLevel { 15 | 16 | public static final byte ENCRYPT_OFF = 0x00; 17 | public static final byte ENCRYPT_ON = 0x01; 18 | public static final byte ENCRYPT_NOT_SUP = 0x02; 19 | public static final byte ENCRYPT_REQ = 0x03; 20 | 21 | private EncryptionLevel() { 22 | // Constants class 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | @ModuleGen(name = "vertx-sql-templates", groupPackage = "io.vertx") 19 | package io.vertx.sqlclient.templates; 20 | 21 | import io.vertx.codegen.annotations.ModuleGen; 22 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/command/PreLoginCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class PreLoginCommand extends CommandBase { 17 | 18 | private final boolean ssl; 19 | 20 | public PreLoginCommand(boolean ssl) { 21 | this.ssl = ssl; 22 | } 23 | 24 | public boolean sslRequired() { 25 | return ssl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/main/java/io/vertx/sqlclient/codec/CommandMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient.codec; 12 | 13 | import io.vertx.core.Completable; 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class CommandMessage> { 17 | 18 | Completable handler; // Should not leak outside of this package 19 | public final C cmd; 20 | 21 | public CommandMessage(C cmd) { 22 | this.cmd = cmd; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | @ModuleGen(name = "vertx-sql-templates", groupPackage = "io.vertx") 19 | package io.vertx.tests.sqlclient.templates; 20 | 21 | import io.vertx.codegen.annotations.ModuleGen; 22 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/junit/TestUtil.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.db2client.junit; 2 | 3 | import java.util.Arrays; 4 | 5 | import io.vertx.ext.unit.TestContext; 6 | 7 | public class TestUtil { 8 | 9 | public static void assertContains(TestContext ctx, String fullString, String... lookFor) { 10 | if (lookFor == null || lookFor.length == 0) 11 | throw new IllegalArgumentException("Must look for at least 1 token"); 12 | ctx.assertNotNull(fullString, "Expected to find '" + lookFor + "' in string, but was null"); 13 | for (String s : lookFor) 14 | if (fullString.contains(s)) 15 | return; // found 16 | if (lookFor.length == 1) 17 | ctx.fail("Expected to find '" + lookFor + "' in string, but was: " + fullString); 18 | else 19 | ctx.fail("Expected to find one of " + Arrays.toString(lookFor) + " in string, but was: " + fullString); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/CommandBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.sqlclient.spi.protocol; 19 | 20 | /** 21 | * @author Julien Viet 22 | */ 23 | 24 | public abstract class CommandBase { 25 | } 26 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/InitDbCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CommandBase; 15 | 16 | public class InitDbCommand extends CommandBase { 17 | private final String schemaName; 18 | 19 | public InitDbCommand(String schemaName) { 20 | this.schemaName = schemaName; 21 | } 22 | 23 | public String schemaName() { 24 | return schemaName; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/NoticeResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | * @author Emad Alblueshi 22 | */ 23 | 24 | public class NoticeResponse extends Response { 25 | } 26 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.utils; 13 | 14 | import java.net.InetAddress; 15 | import java.net.UnknownHostException; 16 | 17 | public final class Utils { 18 | public static String getHostName() { 19 | String hostName; 20 | try { 21 | hostName = InetAddress.getLocalHost().getHostName(); 22 | } catch (UnknownHostException e) { 23 | hostName = ""; 24 | } 25 | return hostName; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLParamDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl; 13 | 14 | import io.vertx.mysqlclient.impl.protocol.ColumnDefinition; 15 | 16 | public class MySQLParamDesc { 17 | private final ColumnDefinition[] paramDefinitions; 18 | 19 | public MySQLParamDesc(ColumnDefinition[] paramDefinitions) { 20 | this.paramDefinitions = paramDefinitions; 21 | } 22 | 23 | public ColumnDefinition[] paramDefinitions() { 24 | return paramDefinitions; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/BooleanTypeSimpleCodecTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.data; 2 | 3 | import io.vertx.sqlclient.Row; 4 | import io.vertx.sqlclient.Tuple; 5 | import io.vertx.ext.unit.TestContext; 6 | import org.junit.Test; 7 | 8 | public class BooleanTypeSimpleCodecTest extends SimpleQueryDataTypeCodecTestBase { 9 | @Test 10 | public void testBoolean1(TestContext ctx) { 11 | testDecodeGeneric(ctx, "true", "BOOLEAN", "TrueValue", Tuple::getBoolean, Row::getBoolean, true); 12 | } 13 | 14 | @Test 15 | public void testBoolean2(TestContext ctx) { 16 | testDecodeGeneric(ctx, "false", "BOOLEAN", "FalseValue", Tuple::getBoolean, Row::getBoolean, false); 17 | } 18 | 19 | @Test 20 | public void testDecodeBOOLArray(TestContext ctx) { 21 | testDecodeGenericArray(ctx, "ARRAY ['TRUE' :: BOOLEAN,'FALSE' :: BOOLEAN]", "BooleanArray", Tuple::getArrayOfBooleans, Row::getArrayOfBooleans, true, false); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/MySQLPreparedQueryPooledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import org.junit.runner.RunWith; 16 | 17 | @RunWith(VertxUnitRunner.class) 18 | public class MySQLPreparedQueryPooledTest extends MySQLPreparedQueryTestBase { 19 | @Override 20 | protected void initConnector() { 21 | options = rule.options(); 22 | connector = ClientConfig.POOLED.connect(vertx, options); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXgIBAAKBgQDdmPB8op+GnhsdfuW91+i/pJsZi7ydPP8OFwi351jx/VJ+Msy0 3 | mEjQEJoE1SsLcXkrTa9qX0RQXwchAWgeatRdVWc3nhK5xr4e4mIkYwHEg87LwQmw 4 | dbJuo13CrdIhRPM4OlhA2NOJNH8OXDo4tk0VH13ViAMJ1pgCYj+D5Xi1twIDAQAB 5 | AoGBAJayIxkfHo1Vh+sPGP15jvaE4lUFCkeD64+RaoRl977ZHvhjY4KM7TdRkuwm 6 | axdlG5mvQtN75eEiPp7bbgsBa1ipeFAfIM0UZkhRdP0vw+BmTnPaymycR4CP3mRO 7 | 0Nsm0TIFnBpEVWJmVL9QHcw7TXqzsxyO+t1+i+s0cqVc8msBAkEA8Zp9vBBD/e2w 8 | 8nWZ+XzY5V3fuZ1TdAaD9g1dGQZ5DQLEV708bsdJuru77YAQP5yKpmvzU5cl3LFC 9 | /3ryja1OMQJBAOrNRLUza8htYA+lgZuloy+E2lSKguyxlkQuagI5YTligFhYkiyo 10 | WuNGNSIMqdAaVZ7eNu3ADKLEjI994f3SQGcCQCdE0QLsMeDn7Ua7Tpd6b1Z4d5CX 11 | vaSyGmi3q1YR80LmHDuWimgHBDjRoq3rjriIHREHorkHbCP+u8ECnsHgVUECQQCB 12 | VU3qTYeqH+0Q0UaB+IvZieFFPgJ95Bf0OGi2Dusp08MEZs0lghqGI87ykW0cLtVI 13 | q/gvn2CWa5NNGrbXu+8zAkEAuI/0x026m7cr1JCQUCAEHqNa9x1mTNmmqGwkArvy 14 | BU0Zt8XlJcrO6uPH/MJCW4OCE48GLFqeSV3dANKhUgsSqg== 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/CloseConnectionMSSQLCommandMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | import io.vertx.sqlclient.spi.protocol.CloseConnectionCommand; 15 | 16 | class CloseConnectionMSSQLCommandMessage extends MSSQLCommandMessage { 17 | CloseConnectionMSSQLCommandMessage(CloseConnectionCommand cmd) { 18 | super(cmd); 19 | } 20 | 21 | @Override 22 | void encode() { 23 | tdsMessageCodec.chctx().channel().close(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/MSSQLDatabaseMetadata.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mssqlclient.impl; 2 | 3 | import io.vertx.sqlclient.spi.DatabaseMetadata; 4 | 5 | public class MSSQLDatabaseMetadata implements DatabaseMetadata { 6 | 7 | private final String fullVersion; 8 | private final int majorVersion; 9 | private final int minorVersion; 10 | 11 | public MSSQLDatabaseMetadata(String fullVersion, int majorVersion, int minorVersion) { 12 | this.fullVersion = fullVersion; 13 | this.majorVersion = majorVersion; 14 | this.minorVersion = minorVersion; 15 | } 16 | 17 | @Override 18 | public String productName() { 19 | return "Microsoft SQL Server"; 20 | } 21 | 22 | @Override 23 | public String fullVersion() { 24 | return fullVersion; 25 | } 26 | 27 | @Override 28 | public int majorVersion() { 29 | return majorVersion; 30 | } 31 | 32 | @Override 33 | public int minorVersion() { 34 | return minorVersion; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ScramClientFinalMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | */ 22 | class ScramClientFinalMessage extends OutboundMessage { 23 | 24 | final String message; 25 | 26 | ScramClientFinalMessage(String message) { 27 | this.message = message; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/DB2QueriesTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.db2client; 2 | 3 | import io.vertx.ext.unit.TestContext; 4 | import io.vertx.ext.unit.junit.VertxUnitRunner; 5 | import io.vertx.sqlclient.Tuple; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | @RunWith(VertxUnitRunner.class) 10 | public class DB2QueriesTest extends DB2TestBase { 11 | 12 | @Test 13 | public void testRowNumber(TestContext ctx) { 14 | connect(ctx.asyncAssertSuccess(conn -> { 15 | conn.preparedQuery("SELECT * FROM (" + 16 | "SELECT id, message, row_number() OVER (ORDER BY id) rn FROM immutable" + 17 | ") r_0_ WHERE r_0_.rn <= ? + ? AND r_0_.rn > ? ORDER BY r_0_.rn").execute(Tuple.of(1, 1, 1)) 18 | .onComplete(ctx.asyncAssertSuccess(rows -> { 19 | ctx.assertEquals(1, rows.size()); 20 | ctx.assertEquals(2, rows.iterator().next().getInteger("rn")); 21 | conn.close(); 22 | })); 23 | })); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/MessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | @SuppressWarnings("unused") 15 | public class MessageStatus { 16 | 17 | public static final short NORMAL = 0x00; 18 | public static final short END_OF_MESSAGE = 0x01; 19 | public static final short IGNORE_THIS_EVENT = 0x02; 20 | public static final short RESET_CONNECTION = 0x08; 21 | public static final short RESET_CONNECTION_SKIP_TRAN = 0x10; 22 | 23 | private MessageStatus() { 24 | // Constants class 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/MySQLPipelinedBatchInsertExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.mysqlclient.MySQLConnectOptions; 16 | import org.junit.runner.RunWith; 17 | 18 | @RunWith(VertxUnitRunner.class) 19 | public class MySQLPipelinedBatchInsertExceptionTest extends MySQLBatchInsertExceptionTestBase { 20 | 21 | protected MySQLConnectOptions createOptions() { 22 | return super.createOptions().setPipeliningLimit(64); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/main/java/io/vertx/sqlclient/templates/RowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient.templates; 12 | 13 | import io.vertx.codegen.annotations.VertxGen; 14 | import io.vertx.sqlclient.Row; 15 | 16 | /** 17 | * Map a {@link Row} to an arbitrary {@code T} object. 18 | */ 19 | @VertxGen 20 | @FunctionalInterface 21 | public interface RowMapper { 22 | 23 | /** 24 | * Build a {@code T} representation of the given {@code row} 25 | * 26 | * @param row the row 27 | * @return the object 28 | */ 29 | T map(Row row); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLPoolOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.mysqlclient.impl; 12 | 13 | import io.vertx.sqlclient.PoolOptions; 14 | 15 | public class MySQLPoolOptions extends PoolOptions { 16 | 17 | public MySQLPoolOptions(PoolOptions other) { 18 | super(other); 19 | } 20 | 21 | private boolean pipelined; 22 | 23 | public boolean isPipelined() { 24 | return pipelined; 25 | } 26 | 27 | public MySQLPoolOptions setPipelined(boolean pipelined) { 28 | this.pipelined = pipelined; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/CloseConnectionCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.sqlclient.spi.protocol; 19 | 20 | public class CloseConnectionCommand extends CommandBase { 21 | 22 | public static final CloseConnectionCommand INSTANCE = new CloseConnectionCommand(); 23 | 24 | private CloseConnectionCommand() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/SetOptionCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.mysqlclient.MySQLSetOption; 15 | import io.vertx.sqlclient.spi.protocol.CommandBase; 16 | 17 | public class SetOptionCommand extends CommandBase { 18 | private final MySQLSetOption mySQLSetOption; 19 | 20 | public SetOptionCommand(MySQLSetOption mySQLSetOption) { 21 | this.mySQLSetOption = mySQLSetOption; 22 | } 23 | 24 | public MySQLSetOption option() { 25 | return mySQLSetOption; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/ErrorCodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.tests.pgclient; 19 | 20 | /** 21 | * @author Julien Viet 22 | */ 23 | public class ErrorCodes { 24 | 25 | public static final String syntax_error = "42601"; 26 | public static final String invalid_text_representation = "22P02"; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/NullSimpleCodecTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.data; 2 | 3 | import io.vertx.pgclient.PgConnection; 4 | import io.vertx.tests.sqlclient.ColumnChecker; 5 | import io.vertx.sqlclient.Row; 6 | import io.vertx.ext.unit.Async; 7 | import io.vertx.ext.unit.TestContext; 8 | import org.junit.Test; 9 | 10 | public class NullSimpleCodecTest extends SimpleQueryDataTypeCodecTestBase { 11 | 12 | @Test 13 | public void testNull(TestContext ctx) { 14 | Async async = ctx.async(); 15 | PgConnection.connect(vertx, options).onComplete(ctx.asyncAssertSuccess(conn -> { 16 | conn 17 | .query("SELECT null \"NullValue\"") 18 | .execute() 19 | .onComplete(ctx.asyncAssertSuccess(result -> { 20 | ctx.assertEquals(1, result.size()); 21 | Row row = result.iterator().next(); 22 | ColumnChecker.checkColumn(0, "NullValue").returnsNull().forRow(row); 23 | async.complete(); 24 | })); 25 | })); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgPreparedBatchTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.tck; 2 | 3 | import io.vertx.ext.unit.junit.VertxUnitRunner; 4 | import io.vertx.tests.pgclient.junit.ContainerPgRule; 5 | import io.vertx.tests.sqlclient.tck.PreparedBatchTestBase; 6 | import org.junit.ClassRule; 7 | import org.junit.runner.RunWith; 8 | 9 | @RunWith(VertxUnitRunner.class) 10 | public class PgPreparedBatchTest extends PreparedBatchTestBase { 11 | @ClassRule 12 | public static ContainerPgRule rule = new ContainerPgRule(); 13 | 14 | @Override 15 | protected String statement(String... parts) { 16 | StringBuilder sb = new StringBuilder(); 17 | for (int i = 0; i < parts.length; i++) { 18 | if (i > 0) { 19 | sb.append("$").append((i)); 20 | } 21 | sb.append(parts[i]); 22 | } 23 | return sb.toString(); 24 | } 25 | 26 | @Override 27 | protected void initConnector() { 28 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/DatabaseMetadata.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.spi; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * Contains static metadata about the backend database server 7 | */ 8 | @VertxGen 9 | public interface DatabaseMetadata { 10 | 11 | /** 12 | * @return The product name of the backend database server 13 | */ 14 | String productName(); 15 | 16 | /** 17 | * @return The full version string for the backend database server. 18 | * This may be useful for for parsing more subtle aspects of the version string. 19 | * For simple information like database major and minor version, use {@link #majorVersion()} 20 | * and {@link #minorVersion()} instead. 21 | */ 22 | String fullVersion(); 23 | 24 | /** 25 | * @return The major version of the backend database server 26 | */ 27 | int majorVersion(); 28 | 29 | /** 30 | * @return The minor version of the backend database server 31 | */ 32 | int minorVersion(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/QueryMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | * @author Emad Alblueshi 22 | */ 23 | class QueryMessage extends OutboundMessage { 24 | 25 | final String sql; 26 | 27 | QueryMessage(String sql) { 28 | this.sql = sql; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.mysql { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.codec; 5 | requires io.netty.common; 6 | requires io.netty.handler; 7 | requires io.netty.transport; 8 | requires io.vertx.sql.client; 9 | requires io.vertx.sql.client.codec; 10 | requires io.vertx.core; 11 | requires io.vertx.core.logging; 12 | requires java.sql; 13 | 14 | provides io.vertx.sqlclient.spi.Driver with io.vertx.mysqlclient.spi.MySQLDriver; 15 | 16 | exports io.vertx.mysqlclient; 17 | exports io.vertx.mysqlclient.spi; 18 | exports io.vertx.mysqlclient.data.spatial; 19 | 20 | exports io.vertx.mysqlclient.impl to io.vertx.tests.sql.client.mysql; 21 | exports io.vertx.mysqlclient.impl.util to io.vertx.tests.sql.client.mysql; 22 | exports io.vertx.mysqlclient.impl.protocol to io.vertx.tests.sql.client.mysql; 23 | 24 | requires static io.vertx.docgen; 25 | requires static io.vertx.codegen.api; 26 | requires static io.vertx.codegen.json; 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlResultImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.sqlclient.impl; 19 | 20 | public class SqlResultImpl extends SqlResultBase { 21 | 22 | private final T value; 23 | 24 | public SqlResultImpl(T value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public T value() { 30 | return value; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /vertx-pg-client/docker/postgres/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | test-postgres: 5 | image: healthcheck/postgres:alpine 6 | ports: 7 | - "5432:5432" 8 | environment: 9 | POSTGRES_USER: postgres 10 | POSTGRES_PASSWORD: postgres 11 | POSTGRES_DB: postgres 12 | volumes: 13 | - /var/run/postgresql:/var/run/postgresql 14 | - ../../src/test/resources/create-postgres.sql:/docker-entrypoint-initdb.d/create-postgres.sql 15 | tls-test-postgres: 16 | image: healthcheck/postgres:alpine 17 | ports: 18 | - "5433:5432" 19 | environment: 20 | POSTGRES_USER: postgres 21 | POSTGRES_PASSWORD: postgres 22 | POSTGRES_DB: postgres 23 | volumes: 24 | - ../../src/test/resources/create-postgres.sql:/docker-entrypoint-initdb.d/create-postgres.sql 25 | - ../../src/test/resources/tls/server.crt:/server.crt 26 | - ../../src/test/resources/tls/server.key:/server.key 27 | - ../../src/test/resources/tls/ssl.sh:/docker-entrypoint-initdb.d/ssl.sh 28 | -------------------------------------------------------------------------------- /vertx-sql-client/src/test/java/io/vertx/tests/sqlclient/tck/Connector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.tests.sqlclient.tck; 18 | 19 | import io.vertx.core.AsyncResult; 20 | import io.vertx.core.Handler; 21 | import io.vertx.sqlclient.SqlClient; 22 | 23 | public interface Connector { 24 | 25 | void connect(Handler> handler); 26 | 27 | void close(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/MSSQLTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient; 13 | 14 | import io.vertx.mssqlclient.MSSQLConnectOptions; 15 | import io.vertx.tests.mssqlclient.junit.MSSQLRule; 16 | import org.junit.BeforeClass; 17 | import org.junit.ClassRule; 18 | 19 | public abstract class MSSQLTestBase { 20 | 21 | @ClassRule 22 | public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE; 23 | 24 | protected static MSSQLConnectOptions options; 25 | 26 | @BeforeClass 27 | public static void before() { 28 | options = rule.options(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/tests/oracleclient/OracleGeneratedKeysPooledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package tests.oracleclient; 13 | 14 | import io.vertx.core.AsyncResult; 15 | import io.vertx.core.Future; 16 | import io.vertx.core.Handler; 17 | import io.vertx.sqlclient.SqlClient; 18 | 19 | import java.util.function.Function; 20 | 21 | public class OracleGeneratedKeysPooledTest extends OracleGeneratedKeysTestBase { 22 | 23 | @Override 24 | protected void withSqlClient(Function> function, Handler> handler) { 25 | function.apply(pool).onComplete(handler); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/tests/oracleclient/OracleGeneratedKeysTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package tests.oracleclient; 13 | 14 | import io.vertx.core.AsyncResult; 15 | import io.vertx.core.Future; 16 | import io.vertx.core.Handler; 17 | import io.vertx.sqlclient.SqlClient; 18 | 19 | import java.util.function.Function; 20 | 21 | public class OracleGeneratedKeysTest extends OracleGeneratedKeysTestBase { 22 | 23 | @Override 24 | protected void withSqlClient(Function> function, Handler> handler) { 25 | pool.withConnection(function::apply).onComplete(handler); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/OracleException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient; 13 | 14 | import io.vertx.sqlclient.DatabaseException; 15 | 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * The {@link DatabaseException} for Oracle. 20 | */ 21 | public class OracleException extends DatabaseException { 22 | 23 | public OracleException(String message, int errorCode, String sqlState) { 24 | super(message, errorCode, sqlState); 25 | } 26 | 27 | public OracleException(SQLException e) { 28 | super(e.getMessage(), e.getErrorCode(), e.getSQLState(), e); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/auth/scram/ScramAuthentication.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl.auth.scram; 2 | 3 | import com.ongres.scram.client.ScramClient; 4 | import io.vertx.core.internal.logging.Logger; 5 | import io.vertx.core.internal.logging.LoggerFactory; 6 | 7 | public class ScramAuthentication { 8 | 9 | private static final Logger logger = LoggerFactory.getLogger(ScramAuthentication.class); 10 | 11 | public static ScramAuthentication INSTANCE; 12 | 13 | static { 14 | ScramAuthentication instance; 15 | try { 16 | ScramClient.MechanismsBuildStage builder = ScramClient.builder(); 17 | logger.debug("Scram authentication is available " + builder); 18 | instance = new ScramAuthentication(); 19 | } catch (Throwable notFound) { 20 | instance = null; 21 | } 22 | INSTANCE = instance; 23 | } 24 | 25 | private ScramAuthentication() { 26 | } 27 | 28 | public ScramSession session(String username, char[] password) { 29 | return new ScramSessionImpl(username, password); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgPreparedQueryCachedTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.tck; 2 | 3 | import io.vertx.ext.unit.junit.VertxUnitRunner; 4 | import io.vertx.tests.pgclient.junit.ContainerPgRule; 5 | import io.vertx.tests.sqlclient.tck.PreparedQueryCachedTestBase; 6 | import org.junit.ClassRule; 7 | import org.junit.runner.RunWith; 8 | 9 | @RunWith(VertxUnitRunner.class) 10 | public class PgPreparedQueryCachedTest extends PreparedQueryCachedTestBase { 11 | @ClassRule 12 | public static ContainerPgRule rule = new ContainerPgRule(); 13 | 14 | @Override 15 | protected void initConnector() { 16 | options = rule.options(); 17 | connector = ClientConfig.CONNECT.connect(vertx, options); 18 | } 19 | 20 | @Override 21 | protected String statement(String... parts) { 22 | StringBuilder sb = new StringBuilder(); 23 | for (int i = 0; i < parts.length; i++) { 24 | if (i > 0) { 25 | sb.append("$").append((i)); 26 | } 27 | sb.append(parts[i]); 28 | } 29 | return sb.toString(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/RowIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.sqlclient; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | 21 | import java.util.Iterator; 22 | 23 | /** 24 | * An iterator for processing rows. 25 | */ 26 | @VertxGen 27 | public interface RowIterator extends Iterator { 28 | 29 | @Override 30 | boolean hasNext(); 31 | 32 | @Override 33 | R next(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/ClosedConnectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient; 12 | 13 | import io.vertx.core.VertxException; 14 | 15 | /** 16 | * When a client operation fails with this exception, the underlying connection may have been lost unexpectedly. 17 | */ 18 | public class ClosedConnectionException extends VertxException { 19 | 20 | public static ClosedConnectionException INSTANCE = new ClosedConnectionException(); 21 | 22 | private ClosedConnectionException() { 23 | super("Failed to read any response from the server, the underlying connection may have been lost unexpectedly.", true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/RowStreamInternal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.sqlclient.impl; 19 | 20 | import io.vertx.sqlclient.Cursor; 21 | import io.vertx.sqlclient.Row; 22 | import io.vertx.sqlclient.RowStream; 23 | 24 | /** 25 | * @author Julien Viet 26 | */ 27 | public interface RowStreamInternal extends RowStream { 28 | 29 | Cursor cursor(); 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/tck/DB2CollectorTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.db2client.tck; 2 | 3 | import org.junit.Before; 4 | import org.junit.ClassRule; 5 | import org.junit.Rule; 6 | import org.junit.rules.TestName; 7 | import org.junit.runner.RunWith; 8 | 9 | import io.vertx.tests.db2client.junit.DB2Resource; 10 | import io.vertx.ext.unit.TestContext; 11 | import io.vertx.ext.unit.junit.VertxUnitRunner; 12 | import io.vertx.tests.sqlclient.tck.CollectorTestBase; 13 | 14 | @RunWith(VertxUnitRunner.class) 15 | public class DB2CollectorTest extends CollectorTestBase { 16 | @ClassRule 17 | public static DB2Resource rule = DB2Resource.SHARED_INSTANCE; 18 | 19 | @Rule 20 | public TestName testName = new TestName(); 21 | 22 | @Before 23 | public void printTestName(TestContext ctx) throws Exception { 24 | System.out.println(">>> BEGIN " + getClass().getSimpleName() + "." + testName.getMethodName()); 25 | } 26 | 27 | @Override 28 | protected void initConnector() { 29 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/AuthenticationDB2CommandBaseMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vertx.db2client.impl.codec; 17 | 18 | import io.vertx.db2client.impl.command.AuthenticationCommandBase; 19 | 20 | abstract class AuthenticationDB2CommandBaseMessage> extends DB2CommandMessage { 21 | 22 | AuthenticationDB2CommandBaseMessage(C cmd) { 23 | super(cmd); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/commands/OracleCloseStatementCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient.impl.commands; 13 | 14 | import io.vertx.core.Future; 15 | import io.vertx.core.internal.ContextInternal; 16 | import oracle.jdbc.OracleConnection; 17 | 18 | public class OracleCloseStatementCommand extends OracleCommand { 19 | 20 | public OracleCloseStatementCommand(OracleConnection oracleConnection, ContextInternal connectionContext) { 21 | super(oracleConnection, connectionContext); 22 | } 23 | 24 | @Override 25 | protected Future execute() { 26 | return Future.succeededFuture(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ScramClientInitialMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | */ 22 | public class ScramClientInitialMessage extends OutboundMessage { 23 | 24 | final String mechanism; 25 | final String message; 26 | 27 | public ScramClientInitialMessage(String message, String mechanism) { 28 | this.message = message; 29 | this.mechanism = mechanism; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/resources/tls/another.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICwTCCAamgAwIBAgIEBeVm4jANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDEwZj 3 | bGllbnQwHhcNMTgwNTI2MTEzNjUxWhcNMjEwNTI1MTEzNjUxWjARMQ8wDQYDVQQD 4 | EwZjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVmCecLdUZ 5 | U917hweVz4JqvZ9vZEi1rH+BG98HYfRR/h3QaobxPImZu3hzKHZ+MPbm94HunLPA 6 | VA9yZhvZMToNfOuD4TUPBPloBuNzwBfZk2O4CaXeG4ailVWUfm5t/l+RD/55zYKu 7 | hw1/Vl9lcOryF2XAmPQ2F1gwEKK7wt1Ak8zw8/yeYgBv1/F+ibCMvR6FVj9ABBEf 8 | TM+oOs4oy51otUv0h63GqYgXMJyLX7q+AGWdC3srwwLQROtkzi7y00g/YryXUoIq 9 | dXEI7CrNL35rZXcZ5LfGRwFX9evX11PpT3OShYlsJBcFE9KMatRoIWd6xUKlxTk0 10 | yLjoOUE2tsMJAgMBAAGjITAfMB0GA1UdDgQWBBQ6xJBQsJCJdj/u0iTLYYD2qQsB 11 | DDANBgkqhkiG9w0BAQsFAAOCAQEAfoquV375+eAGmfnlLxB30v9VhsFckrxFVpYs 12 | XXC6h2G8MtXLpIEpgJo+4SZ4YjNwf/8m9J5j/duU8RukYanyzJdgkFFqKDBYCX7U 13 | SD1nQP7729KnQgxtbR/+i3zkNgo7FATdkLq+HOxklNOEE24Ldenya39bsG779B9n 14 | Sskcbq++7rMM+onDYBv6PbUKCm6nfqPspq809CLxSaUJg9+9ykut6hiyke/i7GEP 15 | XIZHrM+mEvG00ES/zBIdV6TE0AIBP7q2MN7ylT509Ko9sUBMOZdEzikYp5GaRdiv 16 | zG9q6rqK5COK614BwJFOD1DKV1BoDFsgugvfvm/mrc3QfIUPDA== 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/asciidoc/pool_sharing.adoc: -------------------------------------------------------------------------------- 1 | You can share an pool between multiple verticles or instances of the same verticle. Such pool should be created outside 2 | a verticle otherwise it will be closed when the verticle that created it is undeployed 3 | 4 | [source,$lang] 5 | ---- 6 | {@link examples.SqlClientExamples#poolSharing1} 7 | ---- 8 | 9 | You can also create a shared pool in each verticle: 10 | 11 | [source,$lang] 12 | ---- 13 | {@link examples.SqlClientExamples#poolSharing2} 14 | ---- 15 | 16 | The first time a shared pool is created it will create the resources for the pool. Subsequent calls will reuse this pool and create 17 | a lease to this pool. The resources are disposed after all leases have been closed. 18 | 19 | By default, a pool reuses the current event-loop when it needs to create a TCP connection. The shared pool will 20 | therefore randomly use event-loops of verticles using it. 21 | 22 | You can assign a number of event loop a pool will use independently of the context using it 23 | 24 | [source,$lang] 25 | ---- 26 | {@link examples.SqlClientExamples#poolSharing3} 27 | ---- 28 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/Done.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | @SuppressWarnings("unused") 15 | public class Done { 16 | 17 | public static final short STATUS_DONE_FINAL = 0x00; 18 | public static final short STATUS_DONE_MORE = 0x1; 19 | public static final short STATUS_DONE_ERROR = 0x2; 20 | public static final short STATUS_DONE_DONE_INXACT = 0x4; 21 | public static final short STATUS_DONE_COUNT = 0x10; 22 | public static final short STATUS_DONE_ATTN = 0x20; 23 | public static final short STATUS_DONE_SRVERROR = 0x100; 24 | 25 | private Done() { 26 | // Constants class 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/data/SpatialTextCodecTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.data; 13 | 14 | import io.vertx.ext.unit.TestContext; 15 | import io.vertx.ext.unit.junit.VertxUnitRunner; 16 | import io.vertx.sqlclient.Row; 17 | import io.vertx.sqlclient.RowSet; 18 | import org.junit.runner.RunWith; 19 | 20 | import java.util.function.Consumer; 21 | 22 | @RunWith(VertxUnitRunner.class) 23 | public class SpatialTextCodecTest extends SpatialDataTypeCodecTestBase { 24 | @Override 25 | protected void testDecodeGeometry(TestContext ctx, String sql, Consumer> checker) { 26 | testTextDecode(ctx, sql, checker); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/DataFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | * @author Emad Alblueshi 22 | */ 23 | 24 | enum DataFormat { 25 | TEXT(0), 26 | BINARY(1); 27 | final int id; 28 | DataFormat(int id) { 29 | this.id = id; 30 | } 31 | static DataFormat valueOf(int id) { 32 | return (id == 0) ? DataFormat.TEXT : DataFormat.BINARY; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/MSSQLPreparedStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | import io.vertx.sqlclient.internal.PreparedStatement; 15 | import io.vertx.sqlclient.internal.RowDescriptorBase; 16 | 17 | public class MSSQLPreparedStatement implements PreparedStatement { 18 | 19 | final String sql; 20 | int handle; 21 | 22 | public MSSQLPreparedStatement(String sql) { 23 | this.sql = sql; 24 | } 25 | 26 | @Override 27 | public RowDescriptorBase rowDesc() { 28 | throw new UnsupportedOperationException(); 29 | } 30 | 31 | @Override 32 | public String sql() { 33 | return sql; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/data/spatial/Geometry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.data.spatial; 13 | 14 | /** 15 | * Geometry is an abstract class which represents the base of MySQL geometry data type. 16 | */ 17 | public abstract class Geometry { 18 | private long SRID; 19 | 20 | public Geometry() { 21 | } 22 | 23 | public Geometry(Geometry other) { 24 | this.SRID = other.SRID; 25 | } 26 | 27 | public Geometry(long SRID) { 28 | this.SRID = SRID; 29 | } 30 | 31 | public long getSRID() { 32 | return SRID; 33 | } 34 | 35 | public Geometry setSRID(long SRID) { 36 | this.SRID = SRID; 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/DescribeMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | * @author Emad Alblueshi 22 | */ 23 | class DescribeMessage extends OutboundMessage { 24 | 25 | final byte[] statement; 26 | final String portal; 27 | 28 | DescribeMessage(byte[] statement, String portal) { 29 | this.statement = statement; 30 | this.portal = portal; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/tests/oracleclient/tck/OracleSimpleQueryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package tests.oracleclient.tck; 12 | 13 | import io.vertx.ext.unit.junit.VertxUnitRunner; 14 | import tests.oracleclient.junit.OracleRule; 15 | import io.vertx.tests.sqlclient.tck.SimpleQueryTestBase; 16 | import org.junit.ClassRule; 17 | import org.junit.runner.RunWith; 18 | 19 | @RunWith(VertxUnitRunner.class) 20 | public class OracleSimpleQueryTest extends SimpleQueryTestBase { 21 | @ClassRule 22 | public static OracleRule rule = OracleRule.SHARED_INSTANCE; 23 | 24 | @Override 25 | protected void initConnector() { 26 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/tests/oracleclient/tck/OracleDriverTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package tests.oracleclient.tck; 12 | 13 | import io.vertx.ext.unit.junit.VertxUnitRunner; 14 | import tests.oracleclient.junit.OracleRule; 15 | import io.vertx.sqlclient.SqlConnectOptions; 16 | import io.vertx.tests.sqlclient.tck.DriverTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class OracleDriverTest extends DriverTestBase { 22 | 23 | @ClassRule 24 | public static OracleRule rule = OracleRule.SHARED_INSTANCE; 25 | 26 | @Override 27 | protected SqlConnectOptions defaultOptions() { 28 | return rule.options(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgPreparedQueryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.tests.pgclient.tck; 18 | 19 | import io.vertx.ext.unit.junit.VertxUnitRunner; 20 | import org.junit.runner.RunWith; 21 | 22 | @RunWith(VertxUnitRunner.class) 23 | public class PgPreparedQueryTest extends PgPreparedQueryTestBase { 24 | @Override 25 | protected void initConnector() { 26 | options = rule.options(); 27 | connector = ClientConfig.CONNECT.connect(vertx, options); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/tck/MSSQLBatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.tck; 13 | 14 | import io.vertx.tests.mssqlclient.junit.MSSQLRule; 15 | import io.vertx.ext.unit.junit.VertxUnitRunner; 16 | import io.vertx.tests.sqlclient.tck.SimpleQueryTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MSSQLBatchTest extends SimpleQueryTestBase { 22 | @ClassRule 23 | public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/tck/MSSQLCollectorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.tests.mssqlclient.junit.MSSQLRule; 16 | import io.vertx.tests.sqlclient.tck.CollectorTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MSSQLCollectorTest extends CollectorTestBase { 22 | @ClassRule 23 | public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/MySQLCollectorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.tests.mysqlclient.junit.MySQLRule; 16 | import io.vertx.tests.sqlclient.tck.CollectorTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MySQLCollectorTest extends CollectorTestBase { 22 | @ClassRule 23 | public static MySQLRule rule = MySQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/tck/DB2PreparedQueryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.tests.db2client.tck; 18 | 19 | import org.junit.runner.RunWith; 20 | 21 | import io.vertx.ext.unit.junit.VertxUnitRunner; 22 | 23 | @RunWith(VertxUnitRunner.class) 24 | public class DB2PreparedQueryTest extends DB2PreparedQueryTestBase { 25 | @Override 26 | protected void initConnector() { 27 | options = rule.options(); 28 | connector = ClientConfig.CONNECT.connect(vertx, options); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/tck/MSSQLBatchPooledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.tck; 13 | 14 | import io.vertx.tests.mssqlclient.junit.MSSQLRule; 15 | import io.vertx.ext.unit.junit.VertxUnitRunner; 16 | import io.vertx.tests.sqlclient.tck.SimpleQueryTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MSSQLBatchPooledTest extends SimpleQueryTestBase { 22 | @ClassRule 23 | public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.POOLED.connect(vertx, rule.options()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/ServerMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient; 13 | 14 | import io.vertx.codegen.annotations.VertxGen; 15 | 16 | /** 17 | * Describes the server connection mode. 18 | */ 19 | @VertxGen 20 | public enum ServerMode { 21 | 22 | DEDICATED("dedicated"), SHARED("shared"); 23 | 24 | private final String mode; 25 | 26 | ServerMode(String mode) { 27 | this.mode = mode; 28 | } 29 | 30 | public static ServerMode of(String mode) { 31 | return DEDICATED.mode.equalsIgnoreCase(mode) ? DEDICATED : SHARED.mode.equalsIgnoreCase(mode) ? SHARED : null; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return mode; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/asciidoc/cursor.adoc: -------------------------------------------------------------------------------- 1 | == Cursors and streaming 2 | 3 | include::cursor_warning.adoc[opts=optional] 4 | 5 | By default, prepared query execution fetches all rows, you can use a 6 | {@link io.vertx.sqlclient.Cursor} to control the amount of rows you want to read: 7 | 8 | [source,$lang] 9 | ---- 10 | {@link examples.SqlClientExamples#usingCursors01(io.vertx.sqlclient.SqlConnection)} 11 | ---- 12 | 13 | Cursors shall be closed when they are released prematurely: 14 | 15 | [source,$lang] 16 | ---- 17 | {@link examples.SqlClientExamples#usingCursors02(io.vertx.sqlclient.Cursor)} 18 | ---- 19 | 20 | A stream API is also available for cursors, which can be more convenient, specially with the Rxified version. 21 | 22 | [source,$lang] 23 | ---- 24 | {@link examples.SqlClientExamples#usingCursors03(io.vertx.sqlclient.SqlConnection)} 25 | ---- 26 | 27 | The stream read the rows by batch of `50` and stream them, when the rows have been passed to the handler, 28 | a new batch of `50` is read and so on. 29 | 30 | The stream can be resumed or paused, the loaded rows will remain in memory until they are delivered and the cursor 31 | will stop iterating. 32 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/ExtendedQueryMSSQLCommandMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | import io.vertx.sqlclient.internal.TupleBase; 15 | import io.vertx.sqlclient.spi.protocol.ExtendedQueryCommand; 16 | 17 | class ExtendedQueryMSSQLCommandMessage extends ExtendedQueryMSSQLCommandBaseMessage { 18 | 19 | ExtendedQueryMSSQLCommandMessage(ExtendedQueryCommand cmd, MSSQLPreparedStatement ps) { 20 | super(cmd, ps); 21 | } 22 | 23 | @Override 24 | protected TupleBase prepexecRequestParams() { 25 | return cmd.params(); 26 | } 27 | 28 | @Override 29 | protected TupleBase execRequestParams() { 30 | return cmd.params(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/MySQLSimpleQueryPooledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.tests.mysqlclient.junit.MySQLRule; 15 | import io.vertx.tests.sqlclient.tck.SimpleQueryTestBase; 16 | import io.vertx.ext.unit.junit.VertxUnitRunner; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MySQLSimpleQueryPooledTest extends SimpleQueryTestBase { 22 | @ClassRule 23 | public static MySQLRule rule = MySQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.POOLED.connect(vertx, rule.options()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/MySQLClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient; 13 | 14 | import io.vertx.codegen.annotations.VertxGen; 15 | import io.vertx.sqlclient.PropertyKind; 16 | 17 | /** 18 | * An interface to define MySQL specific constants or behaviors. 19 | */ 20 | @VertxGen 21 | public interface MySQLClient { 22 | /** 23 | * SqlResult {@link PropertyKind property kind} for MySQL last_insert_id.
24 | * The property kind can be used to fetch the auto incremented id of the last row when executing inserting or updating operations. 25 | * The property name is {@code last-inserted-id}. 26 | */ 27 | PropertyKind LAST_INSERTED_ID = PropertyKind.create("last-inserted-id", Long.class); 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/MySQLException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient; 13 | 14 | import io.vertx.sqlclient.DatabaseException; 15 | 16 | /** 17 | * The {@link DatabaseException} for MySQL. 18 | */ 19 | public class MySQLException extends DatabaseException { 20 | 21 | public MySQLException(String errorMessage, int errorCode, String sqlState) { 22 | super(formatMessage(errorMessage, errorCode, sqlState), errorCode, sqlState); 23 | } 24 | 25 | private static String formatMessage(String errorMessage, int errorCode, String sqlState) { 26 | return "{" + 27 | "errorMessage=" + errorMessage + 28 | ", errorCode=" + errorCode + 29 | ", sqlState=" + sqlState + 30 | "}"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/codec/MySQLPacketDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.codec; 13 | 14 | import io.netty.buffer.ByteBuf; 15 | import io.netty.handler.codec.LengthFieldBasedFrameDecoder; 16 | 17 | import java.nio.ByteOrder; 18 | 19 | import static io.vertx.mysqlclient.impl.protocol.Packets.PACKET_PAYLOAD_LENGTH_LIMIT; 20 | 21 | public class MySQLPacketDecoder extends LengthFieldBasedFrameDecoder { 22 | 23 | public MySQLPacketDecoder() { 24 | super(4 + PACKET_PAYLOAD_LENGTH_LIMIT, 0, 3, 1, 0); 25 | } 26 | 27 | @Override 28 | protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) { 29 | return buf.getUnsignedMediumLE(offset); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/ProxySQLBatchInsertExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.mysqlclient.MySQLConnectOptions; 16 | import io.vertx.tests.mysqlclient.junit.ProxySQLRule; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class ProxySQLBatchInsertExceptionTest extends MySQLBatchInsertExceptionTestBase { 22 | 23 | @ClassRule 24 | public static ProxySQLRule proxySql = new ProxySQLRule(rule); 25 | 26 | @Override 27 | protected MySQLConnectOptions createOptions() { 28 | return proxySql.options(super.createOptions()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module io.vertx.sql.client.pg { 2 | 3 | requires io.netty.buffer; 4 | requires io.netty.codec; 5 | requires io.netty.common; 6 | requires io.netty.handler; 7 | requires io.netty.transport; 8 | requires io.vertx.sql.client; 9 | requires io.vertx.sql.client.codec; 10 | requires io.vertx.core; 11 | requires io.vertx.core.logging; 12 | requires java.sql; 13 | 14 | requires static com.ongres.scram.client; 15 | requires static com.ongres.scram.common; 16 | 17 | provides io.vertx.sqlclient.spi.Driver with io.vertx.pgclient.spi.PgDriver; 18 | 19 | exports io.vertx.pgclient; 20 | exports io.vertx.pgclient.spi; 21 | exports io.vertx.pgclient.data; 22 | exports io.vertx.pgclient.pubsub; 23 | 24 | exports io.vertx.pgclient.impl to io.vertx.tests.sql.client.pg; 25 | exports io.vertx.pgclient.impl.util to io.vertx.tests.sql.client.pg; 26 | exports io.vertx.pgclient.impl.codec to io.vertx.tests.sql.client.pg; 27 | exports io.vertx.pgclient.impl.pubsub to io.vertx.tests.sql.client.pg; 28 | 29 | requires static io.vertx.docgen; 30 | requires static io.vertx.codegen.api; 31 | requires static io.vertx.codegen.json; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgConnectionTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.tck; 2 | 3 | import io.vertx.tests.pgclient.junit.ContainerPgRule; 4 | import io.vertx.sqlclient.spi.DatabaseMetadata; 5 | import io.vertx.tests.sqlclient.tck.ConnectionTestBase; 6 | import io.vertx.ext.unit.TestContext; 7 | import io.vertx.ext.unit.junit.VertxUnitRunner; 8 | import org.junit.ClassRule; 9 | import org.junit.runner.RunWith; 10 | 11 | @RunWith(VertxUnitRunner.class) 12 | public class PgConnectionTest extends ConnectionTestBase { 13 | @ClassRule 14 | public static ContainerPgRule rule = new ContainerPgRule(); 15 | 16 | @Override 17 | public void setUp() throws Exception { 18 | super.setUp(); 19 | options = rule.options(); 20 | connector = ClientConfig.CONNECT.connect(vertx, options); 21 | } 22 | 23 | @Override 24 | public void tearDown(TestContext ctx) { 25 | connector.close(); 26 | super.tearDown(ctx); 27 | } 28 | 29 | @Override 30 | protected void validateDatabaseMetaData(TestContext ctx, DatabaseMetadata md) { 31 | ctx.assertTrue(md.majorVersion() >= 9); 32 | ctx.assertTrue(md.productName().contains("PostgreSQL")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/resources/mssql.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDATCCAemgAwIBAgIUWxaPUAGmr6h+1gP9P0KWMk3Vua8wDQYJKoZIhvcNAQEL 3 | BQAwDzENMAsGA1UEAwwEc3FsMTAgFw0yMTA3MzAxNDM4NDRaGA8yMTIxMDcwNjE0 4 | Mzg0NFowDzENMAsGA1UEAwwEc3FsMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC 5 | AQoCggEBAOl2vTIPu0h4qK0ociH1S+rJ5ePMjauD7xKyEU7h/SF/eYeXeL2CCe66 6 | C+suuXlhA2nBFFzbNfJGFx2HtM6g8XEq5bE3uOthm0FIacUo1EHQ0Zd3N8cXVAje 7 | UpJLNmoVq4qPK72CHE9ke3Zv6MRi5lnKPjr60wbhypkiOF9WpToTrtjcKsqR6chN 8 | 3TAtpG4QFBjbNZwHkBoYMj+3b7h3ON1WFCpIVeCYVytK+6IWHowBMoH8sGc/iN5X 9 | FZdEjmqidXnwmK9DmLTdEZLTzMiv3uNNCw7Zx99Z6aLWH8efaKuoExMX5BrHHhrS 10 | ua6RjSV+5uBQQrKkbMD7K4dDh3KHYZ0CAwEAAaNTMFEwHQYDVR0OBBYEFKqfPceA 11 | P030gLWWc1xCvrFBwzcCMB8GA1UdIwQYMBaAFKqfPceAP030gLWWc1xCvrFBwzcC 12 | MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBABDuQbaaLW7Udv8p 13 | lYQZQ7qDuEKnkhOrJaGxLsYSwkiwQmreoldZXOdrmOUGgkSBVPTi/AnYg9EENzSD 14 | pztQ8/lDR1orSDo+oPn8yWMi0EERH786OUeHPFtWaKjH7T6wwM+SAFEvocRXRMZs 15 | QFB26BSzryRB6FLMdKkdMRpVLGUe2grMtoXeokFBq6c/7zyGKrazy+e7j44Gxipa 16 | cD98QKfFuRzIajdmAfZyOlSLxngYzGDTAg+SzziiWHLJkOWXXUX0AXZTC1KTzAhE 17 | NwnnJI/jvnHt86wsW/FZRtROydkUq5maqspt818rLWNs4Nba2wi2uppx8lCNDEi6 18 | Xq5AobI= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PasswordMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | import io.vertx.pgclient.impl.util.MD5Authentication; 21 | 22 | /** 23 | * @author Emad Alblueshi 24 | */ 25 | class PasswordMessage extends OutboundMessage { 26 | 27 | final String hash; 28 | 29 | PasswordMessage(String username, String password, byte[] salt) { 30 | this.hash = salt != null ? MD5Authentication.encode(username, password, salt) : password; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/TxCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.sqlclient.spi.protocol; 13 | 14 | public class TxCommand extends CommandBase { 15 | 16 | public enum Kind { 17 | 18 | BEGIN(), ROLLBACK(), COMMIT(); 19 | 20 | private final String sql; 21 | 22 | Kind() { 23 | this.sql = name(); 24 | } 25 | 26 | public String sql() { 27 | return sql; 28 | } 29 | } 30 | 31 | private final R result; 32 | private final Kind kind; 33 | 34 | public TxCommand(Kind kind, R result) { 35 | this.kind = kind; 36 | this.result = result; 37 | } 38 | 39 | public R result() { 40 | return result; 41 | } 42 | 43 | public Kind kind() { 44 | return kind; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/Db2PoolOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.db2client.impl; 18 | 19 | import io.vertx.sqlclient.PoolOptions; 20 | 21 | public class Db2PoolOptions extends PoolOptions { 22 | 23 | public Db2PoolOptions(PoolOptions other) { 24 | super(other); 25 | } 26 | 27 | private boolean pipelined; 28 | 29 | public boolean isPipelined() { 30 | return pipelined; 31 | } 32 | 33 | public Db2PoolOptions setPipelined(boolean pipelined) { 34 | this.pipelined = pipelined; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/resources/tls/files/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDAzCCAeugAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MTowOAYDVQQDDDFNeVNR 3 | TF9TZXJ2ZXJfOC4wLjE3X0F1dG9fR2VuZXJhdGVkX0NBX0NlcnRpZmljYXRlMB4X 4 | DTE5MDkwMjAzMjc1MVoXDTI5MDgzMDAzMjc1MVowPDE6MDgGA1UEAwwxTXlTUUxf 5 | U2VydmVyXzguMC4xN19BdXRvX0dlbmVyYXRlZF9DQV9DZXJ0aWZpY2F0ZTCCASIw 6 | DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANq0q3Ojg961dvC48rcdcfQbAUs3 7 | oJLJP9EAaGxe/YUL1WyedxZTpsMIlX3gR3HzLGJ/KEUUpu6yXFxYDb3uSGGNGlZj 8 | Hy0i445gj00Q/uN4dfThkxXVlbu/i4YrhW2dAmztkO5oxZ9YVTpC0cZ0qGakDyKH 9 | Hl2XC1WzkbKlH2AhmD+CnPh/TZhZlU4N6lp7Hvf+skrXXfHTBK662yat9vHBTRoE 10 | iPBj6fVnuorQze7uP82qcACK6ZTlFJDNWsyf9BuEioT3ykYUBz+Xn8WR85Ux2RbX 11 | jY85c7iboH9gVuf687ndvwXKMv5RsZy4p5wUjrT2Yz2zFRcFF4VZXjPotqcCAwEA 12 | AaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAksGX6UMAwMGi 13 | HTsHh6qnmgwp8x+WvzLSrc/6UvfkcwCmb9du6hAVZqMFqUKztQqUEQJCRGOL3xtR 14 | KuJAVcMum2F0rNVm/cyag2yPm5K372KqMGlCi/Q/Wyd4rj+TkiGN8wNn4f3TGBou 15 | DLufGQnetK7Ad4zKHD3/ZbJQan+wWkgstfYvJ3Ftu/qy4gAe7mnHS43MovTwTSQS 16 | zF63JbQ0dc8I8rQEmVS16s3RYQqIYSHWnNC7/ohxgCaGfRFemt1KYLH8LiKbrke2 17 | rVOHFrNXH3rymGvyNLLXMTJ4yDcavPGMlr8R673sMRTyjByC3gN1NtuJpL9as3Lh 18 | RjXgmM4+ig== 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/resources/tls/files/client-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDBDCCAeygAwIBAgIBAzANBgkqhkiG9w0BAQsFADA8MTowOAYDVQQDDDFNeVNR 3 | TF9TZXJ2ZXJfOC4wLjE3X0F1dG9fR2VuZXJhdGVkX0NBX0NlcnRpZmljYXRlMB4X 4 | DTE5MDkwMjAzMjc1MloXDTI5MDgzMDAzMjc1MlowQDE+MDwGA1UEAww1TXlTUUxf 5 | U2VydmVyXzguMC4xN19BdXRvX0dlbmVyYXRlZF9DbGllbnRfQ2VydGlmaWNhdGUw 6 | ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDj4K1XixgG0/fj0xOqVHt/ 7 | IksEZfp/aQTM8jn+L6IR9nuo6PoGZeDwKjeZjac8rq/JLTkJCYYZCZOrjLqqbl+X 8 | yNxMg1mRtGoLLpJNRt2RjMyAzeBcmGnm2HNvBgVwjaUv3Ar+o+MLL/l+CiPaqSmu 9 | dTpZO9RyWhNLo8rE40at6HUHsree1Nzyo+qtLaTrnT5OZl23XeFBF8SjFi+zlK5K 10 | N75dRkIpt5eUtBrc1Va8mMAN6WCSOAMijq+HvEmAHNNVv43prm0nyQO2SgtDZi9e 11 | 7UxbMzuHwtW8TAUQh5oUiKJnliJoRO0K/QGPCZL9RSj/R8NGRYiD9a0uUvQLCWQ7 12 | AgMBAAGjDTALMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQELBQADggEBAJjCBLVOAPwY 13 | Ocdy2X1NdMOpLNt0bsiReweT/on7LIedrctzFPCtLNqx2sRLPa9nUiw8YureaCjq 14 | xvRC6t/zFWfH3NM1fc3aEF+NR4ceU0+5laJr+bCsDkFB72uz8Gs332D8srX7Tupe 15 | qpD1WTZoPF70h+0yCy5sdkmglMqMmYEk9FQuv0MwXpYbfXVg90ISJuiE6Emzcjtc 16 | wEMycrVL63tRSvytXBgxo18Yqcfyc+MBPXMpEZwUbPL5wle0QNJnps1FS82pB67U 17 | +raB00Hra38cCVf0+4pRuov5VUFUByCX2iKz6Loaez4flJSQjUthhtu20N6wLmUc 18 | +sdPlwFFOSk= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/desc/RowDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient.desc; 12 | 13 | import io.vertx.codegen.annotations.VertxGen; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Describe a database row. 19 | */ 20 | @VertxGen 21 | public interface RowDescriptor { 22 | 23 | /** 24 | * Get the index of the named column or {@literal -1} when not found 25 | * @param columnName the column to lookup 26 | * @return the index of the column 27 | */ 28 | int columnIndex(String columnName); 29 | 30 | /** 31 | * @return the list of the column names 32 | */ 33 | List columnNames(); 34 | 35 | /** 36 | * @return the list of column descriptors 37 | */ 38 | List columnDescriptors(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/OracleClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient; 13 | 14 | import io.vertx.codegen.annotations.VertxGen; 15 | import io.vertx.sqlclient.PropertyKind; 16 | import io.vertx.sqlclient.Row; 17 | 18 | /** 19 | * An interface to define Oracle specific constants or behaviors. 20 | */ 21 | @VertxGen 22 | public interface OracleClient { 23 | 24 | /** 25 | * The property to be used to retrieve the generated keys 26 | */ 27 | PropertyKind GENERATED_KEYS = PropertyKind.create("generated-keys", Row.class); 28 | 29 | /** 30 | * The property to be used to retrieve the output of the callable statement 31 | */ 32 | PropertyKind OUTPUT = PropertyKind.create("callable-statement-output", Boolean.class); 33 | } 34 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/command/PreLoginResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.command; 13 | 14 | import io.vertx.mssqlclient.impl.MSSQLDatabaseMetadata; 15 | 16 | import java.util.Objects; 17 | 18 | public class PreLoginResponse { 19 | 20 | private final MSSQLDatabaseMetadata metadata; 21 | private final Byte encryptionLevel; 22 | 23 | public PreLoginResponse(MSSQLDatabaseMetadata metadata, Byte encryptionLevel) { 24 | this.metadata = Objects.requireNonNull(metadata); 25 | this.encryptionLevel = Objects.requireNonNull(encryptionLevel); 26 | } 27 | 28 | public MSSQLDatabaseMetadata metadata() { 29 | return metadata; 30 | } 31 | 32 | public Byte encryptionLevel() { 33 | return encryptionLevel; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SingletonSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package io.vertx.sqlclient.impl; 12 | 13 | import io.vertx.core.Future; 14 | 15 | import java.util.function.Supplier; 16 | 17 | public class SingletonSupplier implements Supplier> { 18 | 19 | public static Supplier> wrap(C connectOptions) { 20 | return new SingletonSupplier<>(connectOptions); 21 | } 22 | 23 | private final C instance; 24 | private final Future fut; 25 | 26 | private SingletonSupplier(C instance) { 27 | this.instance = instance; 28 | this.fut = Future.succeededFuture(instance); 29 | } 30 | 31 | public C unwrap() { 32 | return instance; 33 | } 34 | 35 | @Override 36 | public Future get() { 37 | return fut; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vertx-sql-client/src/test/java/io/vertx/tests/sqlclient/ArrayTupleTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.tests.sqlclient; 19 | 20 | import io.vertx.sqlclient.Tuple; 21 | import io.vertx.sqlclient.internal.ArrayTuple; 22 | import org.junit.Test; 23 | 24 | import static org.junit.Assert.assertEquals; 25 | 26 | public class ArrayTupleTest { 27 | 28 | @Test 29 | public void testInitialZeroSize() { 30 | Tuple tuple = new ArrayTuple(0); 31 | tuple.addString("the_value"); 32 | assertEquals(1, tuple.size()); 33 | assertEquals("the_value", tuple.getValue(0)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/command/ChangeUserCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.impl.command; 13 | 14 | import io.vertx.core.buffer.Buffer; 15 | import io.vertx.mysqlclient.impl.MySQLCollation; 16 | 17 | import java.util.Map; 18 | 19 | public class ChangeUserCommand extends AuthenticationCommandBase { 20 | public ChangeUserCommand(String username, 21 | String password, 22 | String database, 23 | MySQLCollation collation, 24 | Buffer serverRsaPublicKey, 25 | Map connectionAttributes) { 26 | super(username, password, database, collation, serverRsaPublicKey, connectionAttributes); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/ProxySQLPreparedBatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.mysqlclient.MySQLConnectOptions; 16 | import io.vertx.tests.mysqlclient.junit.ProxySQLRule; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class ProxySQLPreparedBatchTest extends MySQLPreparedBatchTest { 22 | 23 | @ClassRule 24 | public static ProxySQLRule proxySql = new ProxySQLRule(rule); 25 | 26 | @Override 27 | protected void initConnector() { 28 | MySQLConnectOptions options = proxySql.options(rule.options()); 29 | connector = ClientConfig.CONNECT.connect(vertx, options); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/TransactionRollbackException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.sqlclient; 18 | 19 | import io.vertx.core.VertxException; 20 | 21 | /** 22 | * Failure reported to the {@link Transaction#completion()} future when the database server reports the current transaction is failed. 23 | */ 24 | public class TransactionRollbackException extends VertxException { 25 | 26 | public static TransactionRollbackException INSTANCE = new TransactionRollbackException(); 27 | 28 | private TransactionRollbackException() { 29 | super("Rollback", true); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgPoolOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.pgclient.impl; 18 | 19 | import io.vertx.sqlclient.PoolOptions; 20 | 21 | public class PgPoolOptions extends PoolOptions { 22 | 23 | public PgPoolOptions(PoolOptions other) { 24 | super(other); 25 | } 26 | 27 | public PgPoolOptions() { 28 | } 29 | 30 | private boolean pipelined; 31 | 32 | public boolean isPipelined() { 33 | return pipelined; 34 | } 35 | 36 | public PgPoolOptions setPipelined(boolean pipelined) { 37 | this.pipelined = pipelined; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/impl/PgRowTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.pgclient.impl; 13 | 14 | import io.vertx.pgclient.impl.PgRow; 15 | import io.vertx.tests.sqlclient.TestRowDescriptor; 16 | import org.junit.Test; 17 | 18 | import java.time.LocalDate; 19 | 20 | import static org.junit.Assert.assertNull; 21 | import static org.junit.Assert.assertThrows; 22 | 23 | public class PgRowTest { 24 | enum EnumValue { 25 | SOME, NONE 26 | } 27 | @Test 28 | public void testGetNullEnum() { 29 | PgRow row = new PgRow(TestRowDescriptor.create("enum")); 30 | row.addValue(null); 31 | assertNull(row.get(EnumValue.class, 0)); 32 | 33 | row.addValue(LocalDate.now()); 34 | assertThrows(ClassCastException.class, () -> row.get(EnumValue.class, 1)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/DB2RowTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.db2client; 13 | 14 | import io.vertx.db2client.impl.DB2Row; 15 | import io.vertx.tests.sqlclient.TestRowDescriptor; 16 | import org.junit.Test; 17 | 18 | import java.time.LocalDate; 19 | 20 | import static org.junit.Assert.assertNull; 21 | import static org.junit.Assert.assertThrows; 22 | 23 | public class DB2RowTest { 24 | enum EnumValue { 25 | SOME, NONE 26 | } 27 | 28 | @Test 29 | public void testGetNullEnum() { 30 | DB2Row row = new DB2Row(TestRowDescriptor.create("enum")); 31 | row.addValue(null); 32 | assertNull(row.get(EnumValue.class, 0)); 33 | 34 | row.addValue(LocalDate.now()); 35 | assertThrows(ClassCastException.class, () -> row.get(EnumValue.class, 1)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/BindMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.pgclient.impl.codec; 19 | 20 | /** 21 | * @author Emad Alblueshi 22 | */ 23 | final class BindMessage extends OutboundMessage { 24 | 25 | final byte[] statement; 26 | final DataType[] paramTypes; 27 | final PgColumnDesc[] resultColumns; 28 | 29 | BindMessage(byte[] statement, DataType[] paramTypes, PgColumnDesc[] resultColumns) { 30 | this.statement = statement; 31 | this.paramTypes = paramTypes; 32 | this.resultColumns = resultColumns; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-sql-client-templates/src/test/java/io/vertx/tests/sqlclient/templates/UserDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.sqlclient.templates; 2 | 3 | import io.vertx.codegen.format.SnakeCase; 4 | import io.vertx.codegen.annotations.DataObject; 5 | import io.vertx.sqlclient.templates.annotations.Column; 6 | import io.vertx.sqlclient.templates.annotations.RowMapped; 7 | import io.vertx.sqlclient.templates.annotations.TemplateParameter; 8 | 9 | @DataObject 10 | @RowMapped(formatter = SnakeCase.class) 11 | public class UserDataObject { 12 | 13 | private long id; 14 | private String firstName; 15 | private String lastName; 16 | 17 | public long getId() { 18 | return id; 19 | } 20 | 21 | public void setId(long id) { 22 | this.id = id; 23 | } 24 | 25 | public String getFirstName() { 26 | return firstName; 27 | } 28 | 29 | @TemplateParameter(name = "first_name") 30 | @Column(name = "first_name") 31 | public void setFirstName(String firstName) { 32 | this.firstName = firstName; 33 | } 34 | 35 | public String getLastName() { 36 | return lastName; 37 | } 38 | 39 | @TemplateParameter(name = "last_name") 40 | @Column(name = "last_name") 41 | public void setLastName(String lastName) { 42 | this.lastName = lastName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/connection/ConnectionFactory.java: -------------------------------------------------------------------------------- 1 | package io.vertx.sqlclient.spi.connection; 2 | 3 | import io.vertx.core.Closeable; 4 | import io.vertx.core.Context; 5 | import io.vertx.core.Future; 6 | import io.vertx.core.*; 7 | import io.vertx.core.internal.ContextInternal; 8 | import io.vertx.sqlclient.SqlConnectOptions; 9 | import io.vertx.sqlclient.spi.Driver; 10 | 11 | /** 12 | * A connection factory, can be obtained from {@link Driver#createConnectionFactory} 13 | */ 14 | public interface ConnectionFactory extends Closeable { 15 | 16 | default Future connect(Context context, Future fut) { 17 | // The future might be on any context or context-less 18 | // So we need to use a specific context promise 19 | Promise promise = ((ContextInternal) context).promise(); 20 | fut.onComplete(promise); 21 | return promise 22 | .future() 23 | .compose(connectOptions -> connect(context, connectOptions)); 24 | 25 | } 26 | 27 | /** 28 | * Create a connection using the given {@code context}. 29 | * 30 | * @param context the context 31 | * @return the future connection 32 | */ 33 | Future connect(Context context, C options); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/CloseStatementCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package io.vertx.sqlclient.spi.protocol; 19 | 20 | import io.vertx.sqlclient.internal.PreparedStatement; 21 | 22 | /** 23 | * @author Julien Viet 24 | */ 25 | public class CloseStatementCommand extends CommandBase { 26 | 27 | private final PreparedStatement statement; 28 | 29 | public CloseStatementCommand(PreparedStatement statement) { 30 | this.statement = statement; 31 | } 32 | 33 | public PreparedStatement statement() { 34 | return statement; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/tck/MSSQLPreparedQueryPooledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.tck; 13 | 14 | import io.vertx.core.Vertx; 15 | import io.vertx.ext.unit.TestContext; 16 | import io.vertx.ext.unit.junit.VertxUnitRunner; 17 | import org.junit.runner.RunWith; 18 | 19 | @RunWith(VertxUnitRunner.class) 20 | public class MSSQLPreparedQueryPooledTest extends MSSQLPreparedQueryTestBase { 21 | @Override 22 | public void setUp(TestContext ctx) throws Exception { 23 | vertx = Vertx.vertx(); 24 | initConnector(); 25 | cleanTestTable(ctx); // need to use batch instead of prepared statements 26 | } 27 | 28 | @Override 29 | protected void initConnector() { 30 | options = rule.options(); 31 | connector = ClientConfig.POOLED.connect(vertx, options); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/FailureUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient.impl; 13 | 14 | import io.vertx.oracleclient.OracleException; 15 | import oracle.jdbc.OracleDatabaseException; 16 | 17 | import java.sql.SQLException; 18 | 19 | public class FailureUtil { 20 | 21 | public static Throwable sanitize(Throwable t) { 22 | if (t instanceof SQLException) { 23 | SQLException e = (SQLException) t; 24 | Throwable cause = e.getCause(); 25 | if (cause instanceof OracleDatabaseException) { 26 | OracleDatabaseException ode = (OracleDatabaseException) cause; 27 | return new OracleException(ode.toString(), e.getErrorCode(), e.getSQLState()); 28 | } 29 | } 30 | return t; 31 | } 32 | 33 | private FailureUtil() { 34 | // Utility 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/test/java/tests/oracleclient/tck/OracleNullValueEncodeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | package tests.oracleclient.tck; 12 | 13 | import io.vertx.ext.unit.junit.VertxUnitRunner; 14 | import tests.oracleclient.junit.OracleRule; 15 | import io.vertx.tests.sqlclient.tck.NullValueEncodeTestBase; 16 | import org.junit.ClassRule; 17 | import org.junit.runner.RunWith; 18 | 19 | @RunWith(VertxUnitRunner.class) 20 | public class OracleNullValueEncodeTest extends NullValueEncodeTestBase { 21 | 22 | @ClassRule 23 | public static OracleRule rule = OracleRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.POOLED.connect(vertx, rule.options()); 28 | } 29 | 30 | @Override 31 | protected String statement(String... parts) { 32 | return "SELECT ? FROM dual"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ClosePortalPgCommandMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.pgclient.impl.codec; 18 | 19 | import io.vertx.sqlclient.spi.protocol.CloseCursorCommand; 20 | 21 | class ClosePortalPgCommandMessage extends PgCommandMessage { 22 | 23 | ClosePortalPgCommandMessage(CloseCursorCommand cmd) { 24 | super(cmd); 25 | } 26 | 27 | @Override 28 | public void encode(PgEncoder out) { 29 | out.writeClosePortal(cmd.id()); 30 | out.writeSync(); 31 | } 32 | 33 | @Override 34 | public void handleCloseComplete() { 35 | // Expected 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/generated/io/vertx/db2client/DB2ConnectOptionsConverter.java: -------------------------------------------------------------------------------- 1 | package io.vertx.db2client; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | import io.vertx.core.json.JsonArray; 5 | 6 | /** 7 | * Converter and mapper for {@link io.vertx.db2client.DB2ConnectOptions}. 8 | * NOTE: This class has been automatically generated from the {@link io.vertx.db2client.DB2ConnectOptions} original class using Vert.x codegen. 9 | */ 10 | public class DB2ConnectOptionsConverter { 11 | 12 | static void fromJson(Iterable> json, DB2ConnectOptions obj) { 13 | for (java.util.Map.Entry member : json) { 14 | switch (member.getKey()) { 15 | case "ssl": 16 | if (member.getValue() instanceof Boolean) { 17 | obj.setSsl((Boolean)member.getValue()); 18 | } 19 | break; 20 | case "pipeliningLimit": 21 | break; 22 | } 23 | } 24 | } 25 | 26 | static void toJson(DB2ConnectOptions obj, JsonObject json) { 27 | toJson(obj, json.getMap()); 28 | } 29 | 30 | static void toJson(DB2ConnectOptions obj, java.util.Map json) { 31 | json.put("ssl", obj.isSsl()); 32 | json.put("pipeliningLimit", obj.getPipeliningLimit()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/PrepareStatementMSSQLMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | import io.vertx.sqlclient.internal.PreparedStatement; 15 | import io.vertx.sqlclient.codec.CommandResponse; 16 | import io.vertx.sqlclient.spi.protocol.PrepareStatementCommand; 17 | 18 | class PrepareStatementMSSQLMessage extends MSSQLCommandMessage { 19 | PrepareStatementMSSQLMessage(PrepareStatementCommand cmd) { 20 | super(cmd); 21 | } 22 | 23 | @Override 24 | void encode() { 25 | // we use sp_prepexec instead of sp_prepare + sp_exec 26 | PreparedStatement preparedStatement = new MSSQLPreparedStatement(cmd.sql()); 27 | tdsMessageCodec.decoder().fireCommandResponse(CommandResponse.success(preparedStatement)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/impl/MSSQLRowTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.impl; 13 | 14 | import io.vertx.mssqlclient.impl.MSSQLRow; 15 | import io.vertx.tests.sqlclient.TestRowDescriptor; 16 | import org.junit.Test; 17 | 18 | import java.time.LocalDate; 19 | 20 | import static org.junit.Assert.assertNull; 21 | import static org.junit.Assert.assertThrows; 22 | 23 | public class MSSQLRowTest { 24 | enum EnumValue { 25 | SOME, NONE 26 | } 27 | 28 | @Test 29 | public void testGetNullEnum() { 30 | MSSQLRow row = new MSSQLRow(TestRowDescriptor.create("enum")); 31 | row.addValue(null); 32 | assertNull(row.get(EnumValue.class, 0)); 33 | 34 | row.addValue(LocalDate.now()); 35 | assertThrows(ClassCastException.class, () -> row.get(EnumValue.class, 1)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/MySQLPreparedBatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.tests.mysqlclient.junit.MySQLRule; 16 | import io.vertx.tests.sqlclient.tck.PreparedBatchTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MySQLPreparedBatchTest extends PreparedBatchTestBase { 22 | @ClassRule 23 | public static MySQLRule rule = MySQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 28 | } 29 | 30 | @Override 31 | protected String statement(String... parts) { 32 | return String.join("?", parts); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/MessageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | @SuppressWarnings("unused") 15 | public class MessageType { 16 | 17 | public static final short SQL_BATCH = 1; 18 | public static final short PRE_TDS7_LOGIN = 2; 19 | public static final short RPC = 3; 20 | public static final short TABULAR_RESULT = 4; 21 | public static final short ATTENTION_SIGNAL = 6; 22 | public static final short BULK_LOAD_DATA = 7; 23 | public static final short FEDERATED_AUTHENTICATION_TOKEN = 8; 24 | public static final short TRANSACTION_MANAGER_REQUEST = 14; 25 | public static final short TDS7_LOGIN = 16; 26 | public static final short SSPI = 17; 27 | public static final short PRE_LOGIN = 18; 28 | 29 | private MessageType() { 30 | // Constants class 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/TdsPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mssqlclient.impl.codec; 13 | 14 | import io.netty.buffer.ByteBuf; 15 | import io.netty.buffer.DefaultByteBufHolder; 16 | 17 | public class TdsPacket extends DefaultByteBufHolder { 18 | 19 | public static final int PACKET_HEADER_SIZE = 8; 20 | 21 | private final short type; 22 | private final short status; 23 | private final int length; 24 | 25 | public TdsPacket(short type, short status, int length, ByteBuf data) { 26 | super(data); 27 | this.type = type; 28 | this.status = status; 29 | this.length = length; 30 | } 31 | 32 | public short type() { 33 | return type; 34 | } 35 | 36 | public short status() { 37 | return status; 38 | } 39 | 40 | public int length() { 41 | return length; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/data/MSSQLQueryNullableDataTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mssqlclient.data; 13 | 14 | import io.vertx.ext.unit.TestContext; 15 | import io.vertx.ext.unit.junit.VertxUnitRunner; 16 | import io.vertx.sqlclient.Row; 17 | import org.junit.runner.RunWith; 18 | 19 | import java.util.function.Consumer; 20 | 21 | @RunWith(VertxUnitRunner.class) 22 | public class MSSQLQueryNullableDataTypeTest extends MSSQLNullableDataTypeTestBase { 23 | @Override 24 | protected void testDecodeValue(TestContext ctx, boolean isNull, String columnName, Consumer checker) { 25 | if (isNull) { 26 | testQueryDecodeGeneric(ctx, "nullable_datatype", columnName, "3", checker); 27 | } else { 28 | testQueryDecodeGeneric(ctx, "nullable_datatype", columnName, "1", checker); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/MySQLNullValueEncodeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.tests.mysqlclient.tck; 13 | 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import io.vertx.tests.mysqlclient.junit.MySQLRule; 16 | import io.vertx.tests.sqlclient.tck.NullValueEncodeTestBase; 17 | import org.junit.ClassRule; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(VertxUnitRunner.class) 21 | public class MySQLNullValueEncodeTest extends NullValueEncodeTestBase { 22 | @ClassRule 23 | public static MySQLRule rule = MySQLRule.SHARED_INSTANCE; 24 | 25 | @Override 26 | protected void initConnector() { 27 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 28 | } 29 | 30 | @Override 31 | protected String statement(String... parts) { 32 | return String.join("?", parts); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/drda/CCSIDConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vertx.db2client.impl.drda; 17 | 18 | import java.nio.charset.Charset; 19 | import java.nio.charset.StandardCharsets; 20 | 21 | public class CCSIDConstants { 22 | 23 | public static final int CCSID_EBCDIC = 500; // 0x01F4 24 | public static final int CCSID_UTF8 = 1208; // 0x04B8 25 | public static final int TARGET_UNICODE_MGR = CCSID_UTF8; 26 | 27 | public static final Charset EBCDIC = Charset.forName("CP1047"); 28 | public static final Charset UTF8 = StandardCharsets.UTF_8; 29 | 30 | private CCSIDConstants() {} 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/spi/protocol/CommandScheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.sqlclient.spi.protocol; 18 | 19 | import io.vertx.core.Completable; 20 | import io.vertx.core.Future; 21 | import io.vertx.core.Promise; 22 | import io.vertx.core.internal.ContextInternal; 23 | 24 | @FunctionalInterface 25 | public interface CommandScheduler { 26 | 27 | default Future schedule(ContextInternal context, CommandBase cmd) { 28 | Promise promise = context.promise(); 29 | schedule(cmd, promise); 30 | return promise.future(); 31 | } 32 | 33 | void schedule(CommandBase cmd, Completable handler); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mssql-client/src/test/java/io/vertx/tests/mssqlclient/tck/MSSQLPreparedBatchTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.mssqlclient.tck; 2 | 3 | import io.vertx.ext.unit.TestContext; 4 | import io.vertx.ext.unit.junit.VertxUnitRunner; 5 | import io.vertx.tests.mssqlclient.junit.MSSQLRule; 6 | import io.vertx.tests.sqlclient.tck.PreparedBatchTestBase; 7 | import org.junit.ClassRule; 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | 12 | @RunWith(VertxUnitRunner.class) 13 | public class MSSQLPreparedBatchTest extends PreparedBatchTestBase { 14 | @ClassRule 15 | public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE; 16 | 17 | @Override 18 | protected String statement(String... parts) { 19 | StringBuilder sb = new StringBuilder(); 20 | for (int i = 0; i < parts.length; i++) { 21 | if (i > 0) { 22 | sb.append("@p").append((i)); 23 | } 24 | sb.append(parts[i]); 25 | } 26 | return sb.toString(); 27 | } 28 | 29 | @Override 30 | protected void initConnector() { 31 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 32 | } 33 | 34 | @Test 35 | @Ignore 36 | @Override 37 | public void testIncorrectNumBatchArguments(TestContext ctx) { 38 | super.testIncorrectNumBatchArguments(ctx); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vertx-sql-client-codec/src/main/java/io/vertx/sqlclient/codec/CommandResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.sqlclient.codec; 13 | 14 | import io.vertx.core.VertxException; 15 | 16 | public class CommandResponse { 17 | 18 | public static CommandResponse failure(String msg) { 19 | return failure(VertxException.noStackTrace(msg)); 20 | } 21 | 22 | public static CommandResponse failure(Throwable cause) { 23 | return new CommandResponse<>(null, cause); 24 | } 25 | 26 | public static CommandResponse success(R result) { 27 | return new CommandResponse<>(result, null); 28 | } 29 | 30 | // The connection that executed the command 31 | final R result; 32 | final Throwable failure; 33 | 34 | private CommandResponse(R result, Throwable failure) { 35 | this.result = result; 36 | this.failure = failure; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/asciidoc/pool_config.adoc: -------------------------------------------------------------------------------- 1 | === Server load balancing 2 | 3 | You can configure the pool with a list of servers instead of a single server. 4 | 5 | [source,$lang] 6 | ---- 7 | {@link examples.SqlClientExamples#poolConfig01} 8 | ---- 9 | 10 | The pool uses a round-robin load balancing when a connection is created to select different servers. 11 | 12 | NOTE: this provides load balancing when the connection is created and not when the connection is borrowed from the pool. 13 | 14 | === Pool connection initialization 15 | 16 | You can use the {@link io.vertx.sqlclient.ClientBuilder#withConnectHandler} to interact with a connection after it 17 | has been created and before it is inserted in a pool. 18 | 19 | [source,$lang] 20 | ---- 21 | {@link examples.SqlClientExamples#poolConfig02} 22 | ---- 23 | 24 | Once you are done with the connection, you should simply close it to signal the pool to use it. 25 | 26 | === Dynamic connection configuration 27 | 28 | You can configure the pool connection details using a Java supplier instead of an instance of `SqlConnectOptions`. 29 | 30 | Since the supplier is asynchronous, it can be used to provide dynamic pool configuration (e.g. password rotation). 31 | 32 | [source,$lang] 33 | ---- 34 | {@link examples.SqlClientExamples#dynamicPoolConfig} 35 | ---- 36 | -------------------------------------------------------------------------------- /vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/DB2ColumnDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.db2client.impl.codec; 13 | 14 | import io.vertx.sqlclient.desc.ColumnDescriptor; 15 | 16 | import java.sql.JDBCType; 17 | 18 | class DB2ColumnDesc implements ColumnDescriptor { 19 | 20 | private final String name; 21 | private final JDBCType type; 22 | 23 | DB2ColumnDesc(String name, JDBCType type) { 24 | this.name = name; 25 | this.type = type; 26 | } 27 | 28 | @Override 29 | public String name() { 30 | return name; 31 | } 32 | 33 | @Override 34 | public JDBCType jdbcType() { 35 | return type; 36 | } 37 | 38 | @Override 39 | public boolean isArray() { 40 | // Array don't seem supported for the moment 41 | return false; 42 | } 43 | 44 | @Override 45 | public String typeName() { 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/data/Cidr.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.data; 2 | 3 | import java.net.Inet4Address; 4 | import java.net.Inet6Address; 5 | import java.net.InetAddress; 6 | 7 | /** 8 | * A PostgreSQL classless internet domain routing. 9 | */ 10 | public class Cidr { 11 | private InetAddress address; 12 | private Integer netmask; 13 | 14 | public InetAddress getAddress(){ 15 | return address; 16 | } 17 | public Cidr setAddress(InetAddress address) { 18 | if (address instanceof Inet4Address || address instanceof Inet6Address) { 19 | this.address = address; 20 | } else { 21 | throw new IllegalArgumentException("Invalid IP address type"); 22 | } 23 | return this; 24 | } 25 | 26 | public Integer getNetmask(){ 27 | return netmask; 28 | } 29 | 30 | public Cidr setNetmask(Integer netmask) { 31 | if (netmask != null && ((getAddress() instanceof Inet4Address && (netmask < 0 || netmask > 32)) || 32 | (getAddress() instanceof Inet6Address && (netmask < 0 || netmask > 128)))) { 33 | throw new IllegalArgumentException("Invalid netmask: " + netmask); 34 | } 35 | this.netmask = netmask; 36 | return this; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vertx-oracle-client/src/main/java/io/vertx/oracleclient/impl/commands/OracleCloseCursorCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.oracleclient.impl.commands; 13 | 14 | import io.vertx.core.Future; 15 | import io.vertx.core.internal.ContextInternal; 16 | import io.vertx.oracleclient.impl.RowReader; 17 | import oracle.jdbc.OracleConnection; 18 | 19 | public class OracleCloseCursorCommand extends OracleCommand { 20 | 21 | private final RowReader reader; 22 | 23 | public OracleCloseCursorCommand(OracleConnection oracleConnection, ContextInternal connectionContext, RowReader reader) { 24 | super(oracleConnection, connectionContext); 25 | this.reader = reader; 26 | } 27 | 28 | @Override 29 | protected Future execute() { 30 | if (reader == null) { 31 | return Future.succeededFuture(); 32 | } 33 | return reader.close(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/DataTypeCodecTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.tests.pgclient.data; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import io.vertx.pgclient.impl.codec.DataType; 6 | import io.vertx.pgclient.impl.codec.DataTypeCodec; 7 | import org.junit.Test; 8 | 9 | import java.nio.charset.StandardCharsets; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | 15 | public class DataTypeCodecTest { 16 | 17 | @Test 18 | public void testDecodeTextArray() { 19 | assertTextArray("{foo}", "foo"); 20 | assertTextArray("{foo,bar}", "foo", "bar"); 21 | assertTextArray("{\"foo\",bar}", "foo", "bar"); 22 | assertTextArray("{foo,\"bar\"}", "foo", "bar"); 23 | assertTextArray("{foo,\"ba\\\"r\"}", "foo", "ba\"r"); 24 | assertTextArray("{foo,\"bar\\\"\"}", "foo", "bar\""); 25 | assertTextArray("{foo,\"bar\\\\\"}", "foo", "bar\\"); 26 | } 27 | 28 | private void assertTextArray(String data, String... expected) { 29 | ByteBuf buff = Unpooled.copiedBuffer(data, StandardCharsets.UTF_8); 30 | List res = Arrays.asList((String[]) DataTypeCodec.decodeText(DataType.TEXT_ARRAY, 0, buff.readableBytes(), buff)); 31 | assertEquals(Arrays.asList(expected), res); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/ErrorMessageFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.sqlclient.impl; 13 | 14 | /** 15 | * A factory for building error messages. 16 | */ 17 | public class ErrorMessageFactory { 18 | public static String buildWhenArgumentsLengthNotMatched(int expectedNumber, int actualNumber) { 19 | return String.format("The number of parameters to execute should be consistent with the expected number of parameters = [%d] but the actual number is [%d].", expectedNumber, actualNumber); 20 | } 21 | 22 | public static String buildWhenArgumentsTypeNotMatched(Class expectedClass, int pos, Object value) { 23 | return String.format("Parameter at position[%d] with class = [%s] and value = [%s] can not be coerced to the expected class = [%s] for encoding.", pos, value.getClass().getName(), String.valueOf(value), expectedClass.getName()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgDatabaseMetadata.java: -------------------------------------------------------------------------------- 1 | package io.vertx.pgclient.impl; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import io.vertx.sqlclient.spi.DatabaseMetadata; 7 | 8 | public class PgDatabaseMetadata implements DatabaseMetadata { 9 | 10 | private static final Pattern VERSION_PATTERN = Pattern.compile( 11 | "^(\\d+)(?:\\.(\\d+))?"); 12 | 13 | private final String fullVersion; 14 | private int majorVersion; 15 | private int minorVersion; 16 | 17 | public PgDatabaseMetadata(String serverVersion) { 18 | fullVersion = serverVersion; 19 | Matcher matcher = VERSION_PATTERN.matcher(serverVersion); 20 | if (matcher.find()) { 21 | majorVersion = Integer.parseInt(matcher.group(1)); 22 | String minorPart = matcher.group(2); 23 | if (minorPart != null) { 24 | minorVersion = Integer.parseInt(minorPart); 25 | } 26 | } 27 | } 28 | 29 | @Override 30 | public String productName() { 31 | return "PostgreSQL"; 32 | } 33 | 34 | @Override 35 | public String fullVersion() { 36 | return fullVersion; 37 | } 38 | 39 | @Override 40 | public int majorVersion() { 41 | return majorVersion; 42 | } 43 | 44 | @Override 45 | public int minorVersion() { 46 | return minorVersion; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-db2-client/src/test/java/io/vertx/tests/db2client/DB2PingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vertx.tests.db2client; 17 | 18 | import io.vertx.db2client.DB2Connection; 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | 22 | import io.vertx.ext.unit.TestContext; 23 | import io.vertx.ext.unit.junit.VertxUnitRunner; 24 | 25 | @RunWith(VertxUnitRunner.class) 26 | public class DB2PingTest extends DB2TestBase { 27 | 28 | @Test 29 | public void testPingCommand(TestContext ctx) { 30 | DB2Connection.connect(vertx, options).onComplete(ctx.asyncAssertSuccess(conn -> { 31 | conn.ping().onComplete(ctx.asyncAssertSuccess(v -> { 32 | conn.close(); 33 | })); 34 | })); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/data/spatial/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.data.spatial; 13 | 14 | /** 15 | * A Point is a geometry that represents a single location in coordinate space. 16 | */ 17 | public class Point extends Geometry { 18 | private double x, y; 19 | 20 | public Point() { 21 | } 22 | 23 | public Point(Point other) { 24 | super(other); 25 | this.x = other.x; 26 | this.y = other.y; 27 | } 28 | 29 | public Point(long SRID, double x, double y) { 30 | super(SRID); 31 | this.x = x; 32 | this.y = y; 33 | } 34 | 35 | public double getX() { 36 | return x; 37 | } 38 | 39 | public Point setX(double x) { 40 | this.x = x; 41 | return this; 42 | } 43 | 44 | public Point setY(double y) { 45 | this.y = y; 46 | return this; 47 | } 48 | 49 | public double getY() { 50 | return y; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/java/io/vertx/sqlclient/desc/ColumnDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.sqlclient.desc; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | 21 | import java.sql.JDBCType; 22 | 23 | @VertxGen 24 | public interface ColumnDescriptor { 25 | 26 | /** 27 | * @return the column name 28 | */ 29 | String name(); 30 | 31 | /** 32 | * @return whether the column is an array 33 | */ 34 | boolean isArray(); 35 | 36 | /** 37 | * @return vendor-specific name of the column type, or {@code null} if unknown 38 | */ 39 | String typeName(); 40 | 41 | /** 42 | * @return the most appropriate {@code JDBCType} 43 | */ 44 | JDBCType jdbcType(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/test/resources/tls/files/server-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDZDCCAkygAwIBAgIUfAA0jelPI0Xwr+tkPO8Oz7OnNZkwDQYJKoZIhvcNAQEN 3 | BQAwPDE6MDgGA1UEAwwxTXlTUUxfU2VydmVyXzguMC4xN19BdXRvX0dlbmVyYXRl 4 | ZF9DQV9DZXJ0aWZpY2F0ZTAeFw0yNDAzMTExNTE2MDVaFw00NDAzMDYxNTE2MDVa 5 | MBsxGTAXBgNVBAMMEG15c3FsLnZlcnR4LnRlc3QwggEiMA0GCSqGSIb3DQEBAQUA 6 | A4IBDwAwggEKAoIBAQDg00pPuJv078OExAy7wfx/YsPiukl+OpyQAuF/45La5yDI 7 | wx3v55MxYqkX9TCuAIZUprWVllf51sOkNHsB/skCZCYiXFlPmi9nCiK4TAuqN5c0 8 | rdjVdn8eFt4/CeAzHDC2bvoKbnOwDLKtponqbW8unYkXWQDAxYyojxIUc3wNuyPk 9 | efFTkEjuIl3DyhyKZhfFPg0mbDB8t91gSB6oBrEaK9LMHJ4fWDsOSRLru8wUXPds 10 | tMD8zqKQjVfvG/4U5gb+dYycaZ+cRmPgHjarI+StR2ZG9wXs/J1wllciz4fr0je7 11 | +R2j7HHKqTY6JqSz0hZjd1Hej2zWAho1K5KqkDbtAgMBAAGjfzB9MAwGA1UdEwEB 12 | /wQCMAAwHQYDVR0OBBYEFIiHxyASKXMPzKI/uDEi36Afv6ExME4GA1UdIwRHMEWh 13 | QKQ+MDwxOjA4BgNVBAMMMU15U1FMX1NlcnZlcl84LjAuMTdfQXV0b19HZW5lcmF0 14 | ZWRfQ0FfQ2VydGlmaWNhdGWCAQEwDQYJKoZIhvcNAQENBQADggEBAAPIZqs8818j 15 | 7+J6W7WDYlmVRyDK1BH/16/tAAUGSo7IJt09bSp6bm2eAlEp9nDgLLTQSPjfGz+f 16 | Zp1OIdeeKouOFeZfZ5924n7RS1eP49PGD2ZTpk551Rnthni7isL8fOwBx+kZzUIM 17 | 7AQaEi8By5wpwcfNowSMlKR/Wm9OTGqZmmHSixK3HrI6yvHDJwe7fZ6dAl9DDViX 18 | j0hAQnuROsWz3aZkTF3DJ+CGlYjdQvArrazNgsrBbRvAH7VoGYICxahEYMRenXxz 19 | 1Y1ITH7Mi/+53HQge/RoMCVSNQuyVgr3i5fgz5P+GFxdFc0HCC9uanD/PcObOhBs 20 | 38m1J0pH5Q4= 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /vertx-pg-client/src/test/java/io/vertx/tests/pgclient/tck/PgSimpleQueryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Julien Viet 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.vertx.tests.pgclient.tck; 18 | 19 | import io.vertx.tests.pgclient.junit.ContainerPgRule; 20 | import io.vertx.tests.sqlclient.tck.SimpleQueryTestBase; 21 | import io.vertx.ext.unit.junit.VertxUnitRunner; 22 | import org.junit.ClassRule; 23 | import org.junit.runner.RunWith; 24 | 25 | @RunWith(VertxUnitRunner.class) 26 | public class PgSimpleQueryTest extends SimpleQueryTestBase { 27 | 28 | @ClassRule 29 | public static ContainerPgRule rule = new ContainerPgRule(); 30 | 31 | @Override 32 | protected void initConnector() { 33 | connector = ClientConfig.CONNECT.connect(vertx, rule.options()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-sql-client/src/main/asciidoc/connections.adoc: -------------------------------------------------------------------------------- 1 | == Using connections 2 | 3 | === Getting a connection 4 | 5 | When you need to execute sequential queries (without a transaction), you can create a new connection 6 | or borrow one from the pool. Remember that between acquiring the connection from the pool and returning it to the pool, you should take care of the connection because it might be closed by the server for some reason such as an idle time out. 7 | 8 | [source,$lang] 9 | ---- 10 | {@link examples.SqlClientExamples#usingConnections01(io.vertx.core.Vertx, io.vertx.sqlclient.Pool)} 11 | ---- 12 | 13 | Prepared queries can be created: 14 | 15 | [source,$lang] 16 | ---- 17 | {@link examples.SqlClientExamples#usingConnections02(io.vertx.sqlclient.SqlConnection)} 18 | ---- 19 | 20 | === Simplified connection API 21 | 22 | When you use a pool, you can call {@link io.vertx.sqlclient.Pool#withConnection} to pass it a function executed 23 | within a connection. 24 | 25 | It borrows a connection from the pool and calls the function with this connection. 26 | 27 | The function must return a future of an arbitrary result. 28 | 29 | After the future completes, the connection is returned to the pool and the overall result is provided. 30 | 31 | [source,$lang] 32 | ---- 33 | {@link examples.SqlClientExamples#usingConnections03(io.vertx.sqlclient.Pool)} 34 | ---- 35 | -------------------------------------------------------------------------------- /vertx-mysql-client/src/main/java/io/vertx/mysqlclient/data/spatial/LineString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.mysqlclient.data.spatial; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * A LineString is a Curve with linear interpolation between points, it may represents a Line or a LinearRing. 19 | */ 20 | public class LineString extends Geometry { 21 | private List points; 22 | 23 | public LineString() { 24 | } 25 | 26 | public LineString(LineString other) { 27 | super(other); 28 | this.points = new ArrayList<>(other.points); 29 | } 30 | 31 | public LineString(long SRID, List points) { 32 | super(SRID); 33 | this.points = points; 34 | } 35 | 36 | public LineString setPoints(List points) { 37 | this.points = points; 38 | return this; 39 | } 40 | 41 | public List getPoints() { 42 | return points; 43 | } 44 | } 45 | --------------------------------------------------------------------------------