KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > sql > visualeditor > querybuilder > SqlStatement


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.db.sql.visualeditor.querybuilder;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.sql.Connection JavaDoc;
24 import java.sql.SQLException JavaDoc;
25 import javax.sql.DataSource JavaDoc;
26
27 /**
28  * For use by the Query Editor, this describes methods for
29  * getting/setting the sql commnad (in whatever bean it exists) and
30  * obtaining sql connections.
31  *
32  * The Query Editor will initialize itself from the <code>command</code> property
33  * and possible set it's value by calling setCommand().
34  *
35  * The Query Editor will listen for PropertyChangeEvents
36  * for the <code>connectionInfo</code> and <code>command</code> properties .
37  *
38  * A connectionInfo change means the connection info changed and the
39  * query editor should close and then obtain new connections. The query editor
40  * does not care what the old and new values are.
41  * Do a firePropertyChange(CONNECTION_INFO, ...) if the old connections
42  * are no longer valid (data source changed, schema list changed, etc.)
43  *
44  * If the command (sql text) is changed somewhere else, notify the query editor
45  * by changing the <code>command</code> property.
46  *
47  * @author jfbrown
48  */

49 public interface SqlStatement {
50
51     /**
52      * The attribute for a human readable form describing the connection.
53      * A change of this property tells the QueryBuilder that any connections
54      * it holds should be closed.
55      */

56     public static final String JavaDoc CONNECTION_INFO = "connectionInfo" ;
57     /**
58      * the attribute holding the SQL Statement
59      */

60     public static final String JavaDoc COMMAND = "command" ;
61     /**
62      * A property change of this signifies that this object is closing.
63      * Users of this instance of SqlStatment should clean up their references.
64      */

65     public static final String JavaDoc CLOSING = "closing" ;
66     /**
67      * The attibute signifies what QueryBuilder should use for it's
68      * window title.
69      **/

70     public static final String JavaDoc TITLE = "title" ;
71
72     /**
73      * Property nam
74     /**
75      * Obtain a read only connection to the database. Improved performance
76      * may be obtained when using a read only connection.
77      * If you need to update the database, @see #getConnection()
78      *
79      * It is the caller's responsibility to close this connection
80      * when finished.
81      *
82      * @return a valid connection to a database.
83      **/

84     public Connection JavaDoc getReadOnlyConnection() throws SQLException JavaDoc ;
85
86     /**
87      * Obtains a connection to the database.
88      * If the caller does not plan to update the database, the caller
89      * should use @see #getReadOnlyConnection()
90      *
91      * It is the caller's responsibility to close this connection
92      * when finished.
93      *
94      * @return a valid connection to a database.
95      **/

96     public Connection JavaDoc getConnection() throws SQLException JavaDoc ;
97
98
99     /**
100      * Checks to see if the connection is still valid.
101      *
102      * Throws an SQLException if the connection is not not valid.
103      **/

104     public void validateConnection(Connection JavaDoc connection) throws SQLException JavaDoc ;
105
106
107     /**
108      * Get the value of the SQL command.
109      */

110     public String JavaDoc getCommand() ;
111
112     /**
113      * Set the value of the SQL command. This method should fire a
114      * propertyChangeEvent for COMMAND.
115      */

116     public void setCommand(String JavaDoc command) ;
117
118     /**
119      * Gets the connection info. Query Editor uses this value for error dialogs
120      * and debugging messages. Trigger a propertyChangeEvent on the connectionInfo
121      * property whenever the connection changes.
122      */

123     public String JavaDoc getConnectionInfo() ;
124
125     /**
126      * Add a PropertyChangeListener to the listener list. The listener is registered
127      * for all properties.
128      */

129     public void addPropertyChangeListener(PropertyChangeListener JavaDoc listener) ;
130
131     /**
132      * Add a PropertyChangeListener for a specific property. The listener is will be invoked
133      * only for property changes on that specific property.
134      * for all properties.
135      */

136     public void addPropertyChangeListener(String JavaDoc property, PropertyChangeListener JavaDoc listener) ;
137
138     /**
139      * Remove a PropertyChangeListener from the listener list. This removes a
140      * PropertyChangeListener that was registered for all properties.
141      */

142     public void removePropertyChangeListener(PropertyChangeListener JavaDoc listener) ;
143
144     /**
145      * Remove a PropertyChangeListener for a specific property.
146      */

147     public void removePropertyChangeListener(String JavaDoc property, PropertyChangeListener JavaDoc listener) ;
148     
149     /**
150      * Close out all resources because the QueryEditor is closing and
151      * this object is no longer needed.
152      * Use this method to deregister any listeners to other objects, close db connections, etc.
153      */

154     public void close() ;
155    
156     /**
157      * QueryBuilder window title for this statement.
158      */

159     public String JavaDoc getTitle() ;
160     
161     /**
162      * gets an instance of the database's meta data cache to be used for
163      * this sql statement.
164      */

165     public SqlStatementMetaDataCache getMetaDataCache() throws SQLException JavaDoc ;
166   
167 }
168
Popular Tags