{"id":19167522,"url":"https://github.com/tomekw/hucpa","last_synced_at":"2025-05-07T13:41:29.601Z","repository":{"id":56876928,"uuid":"76132690","full_name":"tomekw/hucpa","owner":"tomekw","description":"JRuby wrapper to HikariCP JDBC connection pool","archived":false,"fork":false,"pushed_at":"2017-03-11T14:03:18.000Z","size":474,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T15:42:17.331Z","etag":null,"topics":["connection-pool","jdbc","jruby","jruby-wrapper","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomekw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-10T19:21:55.000Z","updated_at":"2021-10-03T04:21:18.000Z","dependencies_parsed_at":"2022-08-20T23:10:32.033Z","dependency_job_id":null,"html_url":"https://github.com/tomekw/hucpa","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomekw%2Fhucpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomekw%2Fhucpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomekw%2Fhucpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomekw%2Fhucpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomekw","download_url":"https://codeload.github.com/tomekw/hucpa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252889098,"owners_count":21820114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connection-pool","jdbc","jruby","jruby-wrapper","ruby","ruby-gem"],"created_at":"2024-11-09T09:38:02.716Z","updated_at":"2025-05-07T13:41:29.560Z","avatar_url":"https://github.com/tomekw.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hucpa\n\n[![Code Climate](https://codeclimate.com/github/tomekw/hucpa/badges/gpa.svg)](https://codeclimate.com/github/tomekw/hucpa) [![Gem Version](https://badge.fury.io/rb/hucpa.svg)](https://badge.fury.io/rb/hucpa) [![CircleCI](https://circleci.com/gh/tomekw/hucpa.svg?style=svg)](https://circleci.com/gh/tomekw/hucpa)\n\nA JRuby wrapper to [HikariCP](https://github.com/brettwooldridge/HikariCP) - \"zero-overhead\" production ready JDBC connection pool.\nThis is / will be a part of a bigger effort, like a dedicated library to use SQL and / or ActiveRecord integration.\n\nPlease note the project support only JRuby (tested with 9.1.8.0+) on Java 8.\n\nThe public API is subject to change before version `1.0.0`.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"hucpa\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install hucpa\n\n## Configuration options\n\nSee [HikariCP Documentation](https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) for a detailed description.\nNot all HikariCP-defined configuration options are currently supported. To add support for infrequently used options please\nraise an issue or file a pull request.\n\n| Option                  | Required | Default value | Notes                                                                   |\n| ----------------------- | :------: | ------------- | ----------------------------------------------------------------------- |\n| `adapter`               | Yes(1)   | -             | Symbol                                                                  |\n| `auto_commit`           | No       | `true`        | Boolean                                                                 |\n| `connection_test_query` | No       | -             | String                                                                  |\n| `connection_timeout`    | No       | `30_000`      | Integer, greater than or equal to 250, in miliseconds                   |\n| `database_name`         | No       | -             | String                                                                  |\n| `idle_timeout`          | No       | `600_000`     | Integer, 0 (disabled) or greater than or equal to 10000, in miliseconds |\n| `jdbc_url`              | Yes(1)   | -             | String                                                                  |\n| `max_lifetime`          | No       | `1_800_000`   | Integer, 0 (disabled) or greater than or equal to 30000, in miliseconds |\n| `maximum_pool_size`     | No       | `10`          | Integer, greater than or equal to 1                                     |\n| `minimum_idle`          | No       | `10`          | Integer, greater than or equal to 1                                     |\n| `password`              | Yes      | -             | String                                                                  |\n| `pool_name`             | No       | -             | String                                                                  |\n| `server_name`           | No       | -             | String                                                                  |\n| `username`              | Yes      | -             | String                                                                  |\n\n`(1)` - either `adapter` or `jdbc_url` has to be provided.\n\n## Supported adapters and corresponding datasource class names\n\n| Adapter          | Datasource class name                              |\n| ---------------- | -------------------------------------------------- |\n| `db2`            | `com.ibm.db2.jcc.DB2SimpleDataSource`              |\n| `derby`          | `org.apache.derby.jdbc.ClientDataSource`           |\n| `fdbsql`         | `com.foundationdb.sql.jdbc.ds.FDBSimpleDataSource` |\n| `firebird`       | `org.firebirdsql.pool.FBSimpleDataSource`          |\n| `h2`             | `org.h2.jdbcx.JdbcDataSource`                      |\n| `hsqldb`         | `org.hsqldb.jdbc.JDBCDataSource`                   |\n| `mariadb`        | `org.mariadb.jdbc.MySQLDataSource`                 |\n| `mysql`          | `com.mysql.jdbc.jdbc2.optional.MysqlDataSource`    |\n| `oracle`         | `oracle.jdbc.pool.OracleDataSource`                |\n| `pgjdbc_ng`      | `com.impossibl.postgres.jdbc.PGDataSource`         |\n| `postgresql`     | `org.postgresql.ds.PGSimpleDataSource`             |\n| `sqlite`         | `org.sqlite.JDBC`                                  |\n| `sqlserver_jtds` | `net.sourceforge.jtds.jdbcx.JtdsDataSource`        |\n| `sqlserver`      | `com.microsoft.sqlserver.jdbc.SQLServerDataSource` |\n| `sybase`         | `com.sybase.jdbcx.SybDataSource`                   |\n\n## Usage\n\nInstall the database driver, for PostgreSQL:\n\n```ruby\ngem \"jdbc-postgres\"\n```\n\nLoad the the database driver if needed, for PostgreSQL:\n\n```ruby\nrequire \"jdbc/postgres\"\nJdbc::Postgres.load_driver\n```\n\nConfigure the connection pool:\n\n```ruby\n# Using the adapter option\noptions = {\n  adapter: :postgresql,\n  database_name: \"hucpa\",\n  password: \"hucpa\",\n  server_name: \"postgres\",\n  username: \"hucpa\"\n}\n\n# Using the jdbc_url option\noptions = {\n  jdbc_url: \"jdbc:postgresql://postgres/hucpa\",\n  password: \"hucpa\",\n  username: \"hucpa\"\n}\n\nconnection_pool = Hucpa::ConnectionPool.new(options)\n```\n\nUse the connection pool with the `with_connection` API:\n\n\n```ruby\nanswer = connection_pool.with_connection do |connection|\n  result_set =\n    connection\n      .create_statement\n      .execute_query(\"SELECT 42 AS answer\")\n\n  result_set.next and result_set.get_int(\"answer\")\nend\n\nanswer\n=\u003e 42\n```\n\nOr use the connection pool with the \"classic\" API:\n\n```ruby\ndatasource = connection_pool.open\n\n# Explicitly obtain the DB connection\nconnection = datasource.connection\n\nresult_set =\n  connection\n    .create_statement\n    .execute_query(\"SELECT 42 AS answer\")\n\nanswer = result_set.next and result_set.get_int(\"answer\")\n\n# Explicitly release the DB connection\nconnection.close\n\nanswer\n=\u003e 42\n```\n\nClose the connection pool:\n\n```ruby\nconnection_pool.close\n```\n\n## Development\n\nBuild the Docker image:\n\n    $ docker-compose build\n\nCreate services:\n\n    $ docker-compose create\n\nRun specs:\n\n    $ docker-compose run --rm app rspec spec\n\nRun console:\n\n    $ docker-compose run --rm app irb\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tomekw/hucpa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomekw%2Fhucpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomekw%2Fhucpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomekw%2Fhucpa/lists"}