-
Notifications
You must be signed in to change notification settings - Fork 1.1k
spanner-jdbc: Step 18 - ConnectionImpl #5895
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
spanner-jdbc: Step 18 - ConnectionImpl #5895
Conversation
| @Override | ||
| public Thread newThread(Runnable r) { | ||
| Thread t = new Thread(r); | ||
| t.setDaemon(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add a qualifying name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
| this.spannerPool = SpannerPool.INSTANCE; | ||
| this.options = options; | ||
| this.spanner = spannerPool.getSpanner(options, this); | ||
| this.ddlClient = DdlClient.newBuilder().setDatabaseAdminClient(spanner.getDatabaseAdminClient()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this logic to a private method, createDdlClient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a separate method, and moved the assignment to the end of the constructor to ensure that all fields have been initialized.
| } | ||
|
|
||
| @Override | ||
| public StatementResult statementSetAutocommit(Boolean autocommit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should autocommit be autoCommit? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not sure if this is an already defined naming convention elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are used. I have a slight preference for autocommit, but I don't feel very strongly about this.
JDBC uses autoCommit. SQL Server uses auto-commit. PostgreSQL and MySQL use autocommit in their documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One reason to keep this as autocommit is that we have defined the variable AUTOCOMMIT_DML_MODE, which indicates that the driver assumes autocommit to be one word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
7fbf46a to
fababa6
Compare
* add ConnectionImpl * fix CR year * moved DdlClient creation to separate method * updated changed class reference
Adds the implementation class of the internal Spanner connection API. JDBC connections act as wrappers around this class. A ConnectionImpl instance is used to interact with Cloud Spanner through several different types of transactions or batches. There can be at most one transaction or batch active at any one time on a connection.
This PR will have build errors as it depends on step 15 (ConnectionOptions), but also on the different types of transaction classes that will be brought in through separate PRs.