Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Auto-configure emulator when connecting with JDBC #380

Closed
olavloite opened this issue Mar 2, 2021 · 1 comment
Closed

feat: Auto-configure emulator when connecting with JDBC #380

olavloite opened this issue Mar 2, 2021 · 1 comment
Assignees
Labels
api: spanner Issues related to the googleapis/java-spanner-jdbc API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@olavloite
Copy link
Collaborator

Connecting to the Cloud Spanner emulator with JDBC can be a little cumbersome, as

  1. The JDBC driver can only connect to existing instances and databases. A freshly started emulator does not contain any of those.
  2. The user needs to either specify the host and port number of the emulator, and set usePlainText to true, OR set the SPANNER_EMULATOR_HOST environment variable.

The first point makes it very difficult to execute tests against the emulator when using only JDBC, as the instance and database needs to be created by an external program/script before a JDBC connection can be created. It also makes it very difficult to connect to the emulator from generic tools like DBeaver.

Adding a connection option to the JDBC driver to automatically configure and connect to the emulator would make testing a lot easier. When the option is set, the JDBC driver would:

  1. Automatically connect to the default host:port combination of the emulator. This can be overridden by the user if they have chosen a custom host/port.
  2. Automatically turn off authentication and use plain text communication.
  3. Automatically create both the instance and the database that are mentioned in the connection string if any of these do not already exist. Any existing instance/database should be used if it already exists.
@olavloite olavloite added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels Mar 2, 2021
@olavloite olavloite self-assigned this Mar 2, 2021
gcf-merge-on-green bot pushed a commit to googleapis/java-spanner that referenced this issue Mar 17, 2021
Adds `autoConfigEmulator` connection option. When this option is set to true for a connection:
1. The connection will by default try to connect to `localhost:9010` (unless a specific host/port is set in the connection URL).
2. Plain text communication will be enabled.
3. Authentication will be disabled.
4. The instance and database in the connection string will automatically be created on the emulator if any of them do not yet exist. Any existing instance and/or database will remain untouched.

Towards googleapis/java-spanner-jdbc#380
@olavloite
Copy link
Collaborator Author

This feature has been enabled and released in version 2.0.0 thanks to googleapis/java-spanner#931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner-jdbc API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant