01: /*
02:
03: Derby - Class org.apache.derby.client.am.Savepoint
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.client.am;
23:
24: import org.apache.derby.shared.common.reference.SQLState;
25:
26: import java.sql.SQLException;
27:
28: public class Savepoint implements java.sql.Savepoint {
29: // ----------------- internals -----------------------------------------------
30:
31: int savepointId_ = 0;
32: String savepointName_ = null;
33: Agent agent_;
34:
35: //---------------------constructors/finalizer---------------------------------
36:
37: // create a named savepoint.
38: Savepoint(Agent agent, String savepointName) {
39: agent_ = agent;
40: savepointName_ = savepointName;
41: }
42:
43: // create an un-named savepoint.
44: Savepoint(Agent agent, int savepointId) {
45: agent_ = agent;
46: savepointId_ = savepointId;
47: }
48:
49: // ----------------- externals -----------------------------------------------
50:
51: public int getSavepointId() throws SQLException {
52: if (savepointId_ != 0) {
53: return savepointId_;
54: } else {
55: throw new SqlException(agent_.logWriter_,
56: new ClientMessageId(
57: SQLState.NO_ID_FOR_NAMED_SAVEPOINT))
58: .getSQLException();
59: }
60: }
61:
62: public String getSavepointName() throws SQLException {
63: if (savepointName_ != null) {
64: return savepointName_;
65: } else {
66: throw new SqlException(agent_.logWriter_,
67: new ClientMessageId(
68: SQLState.NO_NAME_FOR_UNNAMED_SAVEPOINT))
69: .getSQLException();
70: }
71: }
72: }
|