![]() |
|
mozilla/ extensions/ sql/ base/ public/ mozISqlConnection.idl |
|
|
Inheritance diagram for mozISqlConnection:
Collaboration diagram for mozISqlConnection:
[ mozISqlConnection Interface Reference | Graph Legend ]
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is mozilla.org code.
15 *
16 * The Initial Developer of the Original Code is Jan Varga
17 * Portions created by the Initial Developer are Copyright (C) 2003
18 * the Initial Developer. All Rights Reserved.
19 *
20 * Contributor(s):
21 * Neil Deakin <enndeakin@sympatico.ca>
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
37 #include "nsISupports.idl"
38
39 interface mozISqlResult;
40 interface mozISqlRequest;
41 interface mozISqlRequestObserver;
42
43 /**
44 * A connection to a SQL database. This interface may be further extended
45 * by a particular database implementation. The SQL service is responsible
46 * for creating and maintaining connections, so there isn't a means to create
47 * one directly via this interface.
48 *
49 * @status UNDER_REVIEW
50 */
51
52 [scriptable, uuid(f16397a4-1ecb-4e08-84f8-27750c04b779)]
53 interface mozISqlConnection : nsISupports
54 {
55 /**
56 * A string holding the name and/or version info of the database.
57 */
58 readonly attribute AString serverVersion;
59
60 /**
61 * The most recent error message.
62 */
63 readonly attribute AString errorMessage;
64
65 /**
66 * The ID of the most recently added record.
67 */
68 readonly attribute long lastID;
69
70 /**
71 * Set up the connection. This is called by the SQL service. There is no
72 * need to call this method directly.
73 *
74 * @param aHost the host name.
75 * @param aPort the port at which the host is listening.
76 * @param aDatabase the real database name to connect to.
77 * @param aUsername the username to connect as.
78 * @param aPassword the password to use in authentification phase.
79 */
80 void init(in AString aHost,
81 in long aPort,
82 in AString aDatabase,
83 in AString aUsername,
84 in AString aPassword);
85
86 /**
87 * Execute an SQL query synchronously and return the query result.
88 *
89 * @param aQuery the SQL string of the query to execute
90 * @return the result of the query
91 */
92 mozISqlResult executeQuery(in AString aQuery);
93
94 /**
95 * Execute an SQL update synchronously and return the number of updated
96 * rows.
97 *
98 * @param aUpdate the update to execute
99 * @return the result of the query
100 */
101 long executeUpdate(in AString aUpdate);
102
103 /**
104 * Execute an SQL query asynchronously and return a request. An observer
105 * may be used to track when the query has completed.
106 *
107 * @param aQuery the SQL string of the query to execute
108 * @param aContext extra argument that will be passed to the observer
109 * @param aObserver observer that will be notified when the query is done
110 * @return a request object
111 */
112 mozISqlRequest asyncExecuteQuery(in AString aQuery,
113 in nsISupports aContext,
114 in mozISqlRequestObserver aObserver);
115
116 /**
117 * Execute an SQL update asynchronously and return a request. An observer
118 * may be used to track when the query has completed.
119 *
120 * @param aQuery the SQL string of the update to execute
121 * @param aContext extra argument that will be passed to the observer
122 * @param aObserver observer that will be notified when the update is done
123 * @return a request object
124 */
125 mozISqlRequest asyncExecuteUpdate(in AString aQuery,
126 in nsISupports aContext,
127 in mozISqlRequestObserver aObserver);
128
129 /**
130 * Begin a transaction. Updates made during the transaction will not be
131 * made permanent until it is committed using commitTransaction.
132 */
133 void beginTransaction();
134
135 /**
136 * Commit the current transaction
137 */
138 void commitTransaction();
139
140 /**
141 * Rollback (cancel) the current transaction
142 */
143 void rollbackTransaction();
144
145 /**
146 * Return the primary keys of a given table.
147 *
148 * @param aSchema the schema
149 * @param aTable the table name of the keys to retrieve
150 * @return the result which holds the keys
151 */
152 mozISqlResult getPrimaryKeys(in AString aSchema, in AString aTable);
153
154 };
155