KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sessionEnhydra > persistent > SessionDeleteDO


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: SessionDeleteDO.java,v 1.2 2005/03/24 10:51:20 slobodan Exp $
23  */

24
25 package com.lutris.appserver.server.sessionEnhydra.persistent;
26
27 import java.sql.PreparedStatement JavaDoc;
28 import java.sql.SQLException JavaDoc;
29
30 import com.lutris.appserver.server.sql.DBConnection;
31 import com.lutris.appserver.server.sql.Transaction;
32
33 /**
34  * Database interface that is used to delete a session
35  * from the database.
36  *
37  * @version $Revision: 1.2 $
38  * @author Kyle Clark
39  */

40 public class SessionDeleteDO implements Transaction {
41
42     /**
43      * The session represented by this object.
44      */

45     private String JavaDoc sessionKey;
46
47     /**
48      * @param sessionKey the key identifying the session
49      * that should be deleted.
50      */

51     protected SessionDeleteDO(String JavaDoc sessionKey) {
52         this.sessionKey = sessionKey;
53     }
54
55     /**
56      * Inserts the session into the database.
57      *
58      * @param conn Database connection.
59      * @exception java.sql.SQLException If a database access error
60      * occurs.
61      */

62     public void executeInsert(DBConnection conn)
63         throws SQLException JavaDoc {
64         throw new Error JavaDoc("not supported");
65     }
66
67     /**
68      * If this object's <code>executeInsert</code> method was
69      * called then <code>finalizeInsert</code> is called with
70      * the status of the database transaction. This method
71      * allows the data object to perform any post processing
72      * if the transaction succeeded or failed.
73      *
74      * @param success true if the transaction succeeded
75      * and this object was successfully inserted into the database.
76      */

77     public void finalizeInsert(boolean success) {
78     }
79
80     /**
81      * Method to update contents of object in database.
82      *
83      * @param conn Database connection.
84      * @exception java.sql.SQLException If a database access error
85      * occurs.
86      */

87     public void executeUpdate(DBConnection conn)
88         throws SQLException JavaDoc {
89         throw new Error JavaDoc("not supported");
90     }
91
92     /**
93      * If this object's <code>executeUpdate</code> method was
94      * called then <code>finalizeUpdate</code> is called with
95      * the status of the database transaction.
96      * For instance the data object may want to
97      * increment its version number once it has successfully
98      * been commited to the database.
99      *
100      * @param success true if the transaction succeeded
101      * and this object was successfully updated in the database.
102      */

103     public void finalizeUpdate(boolean success) {
104     }
105
106     /**
107      * Method to delete an object from the database.
108      *
109      * @param conn Database connection.
110      * @exception java.sql.SQLException If a database access error
111      * occurs.
112      */

113     public void executeDelete(DBConnection conn)
114         throws SQLException JavaDoc {
115         String JavaDoc sql = "delete from " + PersistentSessionHome.dbTableName
116             + " where sessionKey = ?";
117         PreparedStatement JavaDoc stmt = conn.prepareStatement(sql);
118         stmt.setString(1,sessionKey);
119         conn.executeUpdate(stmt, sql);
120     }
121
122     /**
123      * If this object's <code>executeDelete</code> method was
124      * called then <code>finalizeDelete</code> is called with
125      * the status of the database transaction.
126      *
127      * @param success true if the transaction succeeded
128      * and this object was successfully deleted from the
129      * database.
130      */

131     public void finalizeDelete(boolean success) {
132         // ignore?
133
}
134
135 }
136
Popular Tags