01: // jTDS JDBC Driver for Microsoft SQL Server and Sybase
02: // Copyright (C) 2004 The jTDS Project
03: //
04: // This library is free software; you can redistribute it and/or
05: // modify it under the terms of the GNU Lesser General Public
06: // License as published by the Free Software Foundation; either
07: // version 2.1 of the License, or (at your option) any later version.
08: //
09: // This library is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: // Lesser General Public License for more details.
13: //
14: // You should have received a copy of the GNU Lesser General Public
15: // License along with this library; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: //
18: package net.sourceforge.jtds.jdbc;
19:
20: import java.sql.Savepoint;
21: import java.sql.SQLException;
22:
23: /**
24: * Savepoint implementation class.
25: *
26: * @author Brian Heineman
27: * @version $Id: SavepointImpl.java,v 1.5 2005/04/28 14:29:27 alin_sinpalean Exp $
28: */
29: class SavepointImpl implements Savepoint {
30: private final int id;
31: private final String name;
32:
33: /**
34: * Constructs a savepoint with a specific identifier.
35: *
36: * @param id a savepoint identifier
37: */
38: SavepointImpl(int id) {
39: this (id, null);
40: }
41:
42: /**
43: * Constructs a savepoint with a specific identifier and name.
44: *
45: * @param id a savepoint identifier
46: * @param name the savepoint name
47: */
48: SavepointImpl(int id, String name) {
49: this .id = id;
50: this .name = name;
51: }
52:
53: public int getSavepointId() throws SQLException {
54: if (name != null) {
55: throw new SQLException(Messages
56: .get("error.savepoint.named"), "HY024");
57: }
58:
59: return id;
60: }
61:
62: public String getSavepointName() throws SQLException {
63: if (name == null) {
64: throw new SQLException(Messages
65: .get("error.savepoint.unnamed"), "HY024");
66: }
67:
68: return name;
69: }
70:
71: /**
72: * Returns the savepoint id. This will not throw an exception for
73: * named savepoints as would {@link #getSavepointId}.
74: *
75: * @return the savepoint id
76: */
77: int getId() {
78: return id;
79: }
80: }
|