|
23 | 23 | import com.google.cloud.spanner.TimestampBound;
|
24 | 24 | import com.google.cloud.spanner.connection.AutocommitDmlMode;
|
25 | 25 | import com.google.cloud.spanner.connection.ConnectionOptions;
|
| 26 | +import com.google.cloud.spanner.connection.SavepointSupport; |
26 | 27 | import com.google.cloud.spanner.connection.TransactionMode;
|
27 | 28 | import com.google.common.collect.Iterators;
|
28 | 29 | import java.sql.Array;
|
|
33 | 34 | import java.sql.PreparedStatement;
|
34 | 35 | import java.sql.ResultSet;
|
35 | 36 | import java.sql.SQLException;
|
| 37 | +import java.sql.Savepoint; |
36 | 38 | import java.sql.Statement;
|
37 | 39 | import java.sql.Timestamp;
|
38 | 40 | import java.util.HashMap;
|
@@ -402,6 +404,70 @@ public String getSchema() throws SQLException {
|
402 | 404 | return "";
|
403 | 405 | }
|
404 | 406 |
|
| 407 | + @Override |
| 408 | + public SavepointSupport getSavepointSupport() throws SQLException { |
| 409 | + checkClosed(); |
| 410 | + return getSpannerConnection().getSavepointSupport(); |
| 411 | + } |
| 412 | + |
| 413 | + @Override |
| 414 | + public void setSavepointSupport(SavepointSupport savepointSupport) throws SQLException { |
| 415 | + checkClosed(); |
| 416 | + try { |
| 417 | + getSpannerConnection().setSavepointSupport(savepointSupport); |
| 418 | + } catch (SpannerException e) { |
| 419 | + throw JdbcSqlExceptionFactory.of(e); |
| 420 | + } |
| 421 | + } |
| 422 | + |
| 423 | + @Override |
| 424 | + public Savepoint setSavepoint() throws SQLException { |
| 425 | + checkClosed(); |
| 426 | + try { |
| 427 | + JdbcSavepoint savepoint = JdbcSavepoint.unnamed(); |
| 428 | + getSpannerConnection().savepoint(savepoint.internalGetSavepointName()); |
| 429 | + return savepoint; |
| 430 | + } catch (SpannerException e) { |
| 431 | + throw JdbcSqlExceptionFactory.of(e); |
| 432 | + } |
| 433 | + } |
| 434 | + |
| 435 | + @Override |
| 436 | + public Savepoint setSavepoint(String name) throws SQLException { |
| 437 | + checkClosed(); |
| 438 | + try { |
| 439 | + JdbcSavepoint savepoint = JdbcSavepoint.named(name); |
| 440 | + getSpannerConnection().savepoint(savepoint.internalGetSavepointName()); |
| 441 | + return savepoint; |
| 442 | + } catch (SpannerException e) { |
| 443 | + throw JdbcSqlExceptionFactory.of(e); |
| 444 | + } |
| 445 | + } |
| 446 | + |
| 447 | + @Override |
| 448 | + public void rollback(Savepoint savepoint) throws SQLException { |
| 449 | + checkClosed(); |
| 450 | + JdbcPreconditions.checkArgument(savepoint instanceof JdbcSavepoint, savepoint); |
| 451 | + JdbcSavepoint jdbcSavepoint = (JdbcSavepoint) savepoint; |
| 452 | + try { |
| 453 | + getSpannerConnection().rollbackToSavepoint(jdbcSavepoint.internalGetSavepointName()); |
| 454 | + } catch (SpannerException e) { |
| 455 | + throw JdbcSqlExceptionFactory.of(e); |
| 456 | + } |
| 457 | + } |
| 458 | + |
| 459 | + @Override |
| 460 | + public void releaseSavepoint(Savepoint savepoint) throws SQLException { |
| 461 | + checkClosed(); |
| 462 | + JdbcPreconditions.checkArgument(savepoint instanceof JdbcSavepoint, savepoint); |
| 463 | + JdbcSavepoint jdbcSavepoint = (JdbcSavepoint) savepoint; |
| 464 | + try { |
| 465 | + getSpannerConnection().releaseSavepoint(jdbcSavepoint.internalGetSavepointName()); |
| 466 | + } catch (SpannerException e) { |
| 467 | + throw JdbcSqlExceptionFactory.of(e); |
| 468 | + } |
| 469 | + } |
| 470 | + |
405 | 471 | @Override
|
406 | 472 | public Timestamp getCommitTimestamp() throws SQLException {
|
407 | 473 | checkClosed();
|
|
0 commit comments