~sgdg/stado/stado25

« back to all changes in this revision

Viewing changes to src/org/postgresql/driver/core/BaseConnection.java

  • Committer: Jim Mlodgenski
  • Date: 2011-08-30 22:39:37 UTC
  • mfrom: (1.1.3 stado)
  • Revision ID: jim@cirrusql.com-20110830223937-25q231a31x0e08b4
Merge from Spatial branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * Copyright (C) 2008 EnterpriseDB Corporation.
 
3
 * Copyright (C) 2011 Stado Global Development Group.
 
4
 *
 
5
 * This file is part of Stado.
 
6
 *
 
7
 * Stado is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * Stado is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with Stado.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * You can find Stado at http://www.stado.us
 
21
 *
 
22
 ****************************************************************************/
 
23
package org.postgresql.driver.core;
 
24
 
 
25
import java.sql.*;
 
26
 
 
27
import org.postgresql.driver.PGConnection;
 
28
import org.postgresql.driver.jdbc2.TimestampUtils;
 
29
 
 
30
/**
 
31
 * Driver-internal connection interface. Application code should not use
 
32
 * this interface.
 
33
 */
 
34
public interface BaseConnection extends PGConnection, Connection
 
35
{
 
36
    /**
 
37
     * Cancel the current query executing on this connection.
 
38
     *
 
39
     * @throws SQLException if something goes wrong.
 
40
     */
 
41
    public void cancelQuery() throws SQLException;
 
42
 
 
43
    /**
 
44
     * Execute a SQL query that returns a single resultset.
 
45
     * Never causes a new transaction to be started regardless of the autocommit setting.
 
46
     *
 
47
     * @param s the query to execute
 
48
     * @return the (non-null) returned resultset
 
49
     * @throws SQLException if something goes wrong.
 
50
     */
 
51
    public ResultSet execSQLQuery(String s) throws SQLException;
 
52
 
 
53
    public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException;
 
54
 
 
55
    /**
 
56
     * Execute a SQL query that does not return results.
 
57
     * Never causes a new transaction to be started regardless of the autocommit setting.
 
58
     *
 
59
     * @param s the query to execute
 
60
     * @throws SQLException if something goes wrong.
 
61
     */
 
62
    public void execSQLUpdate(String s) throws SQLException;
 
63
 
 
64
    /**
 
65
     * Get the QueryExecutor implementation for this connection.
 
66
     *
 
67
     * @return the (non-null) executor
 
68
     */
 
69
    public QueryExecutor getQueryExecutor();
 
70
 
 
71
    /**
 
72
     * Construct and return an appropriate object for the given
 
73
     * type and value. This only considers the types registered via
 
74
     * {@link org.postgresql.driver.PGConnection#addDataType(String,Class)} and
 
75
     * {@link org.postgresql.driver.PGConnection#addDataType(String,String)}.
 
76
     *<p>
 
77
     * If no class is registered as handling the given type, then a generic
 
78
     * {@link org.postgresql.driver.util.PGobject} instance is returned.
 
79
     *
 
80
     * @param type the backend typename
 
81
     * @param value the type-specific string representation of the value
 
82
     * @return an appropriate object; never null.
 
83
     * @throws SQLException if something goes wrong
 
84
     */
 
85
    public Object getObject(String type, String value) throws SQLException;
 
86
 
 
87
    public Encoding getEncoding() throws SQLException;
 
88
 
 
89
    public TypeInfo getTypeInfo();
 
90
 
 
91
    /**
 
92
     * Check if we should use driver behaviour introduced in a particular
 
93
     * driver version. This defaults to behaving as the actual driver's version
 
94
     * but can be overridden by the "compatible" URL parameter.
 
95
     *
 
96
     * @param ver the driver version to check
 
97
     * @return true if the driver's behavioural version is at least "ver".
 
98
     * @throws SQLException if something goes wrong
 
99
     */
 
100
    public boolean haveMinimumCompatibleVersion(String ver);
 
101
 
 
102
    /**
 
103
     * Check if we have at least a particular server version.
 
104
     *
 
105
     * @param ver the server version to check
 
106
     * @return true if the server version is at least "ver".
 
107
     * @throws SQLException if something goes wrong
 
108
     */
 
109
    public boolean haveMinimumServerVersion(String ver);
 
110
 
 
111
    /**
 
112
     * Encode a string using the database's client_encoding
 
113
     * (usually UNICODE, but can vary on older server versions).
 
114
     * This is used when constructing synthetic resultsets (for
 
115
     * example, in metadata methods).
 
116
     *
 
117
     * @param str the string to encode
 
118
     * @return an encoded representation of the string
 
119
     * @throws SQLException if something goes wrong.
 
120
     */
 
121
    public byte[] encodeString(String str) throws SQLException;
 
122
 
 
123
    /**
 
124
     * Escapes a string for use as string-literal within an SQL command. The
 
125
     * method chooses the applicable escaping rules based on the value of
 
126
     * {@link #getStandardConformingStrings()}.
 
127
     * 
 
128
     * @param str a string value
 
129
     * @return the escaped representation of the string
 
130
     * @throws SQLException if the string contains a <tt>\0</tt> character
 
131
     */
 
132
    public String escapeString(String str) throws SQLException;
 
133
 
 
134
    /**
 
135
     * Returns whether the server treats string-literals according to the SQL
 
136
     * standard or if it uses traditional PostgreSQL escaping rules. Versions
 
137
     * up to 8.1 always treated backslashes as escape characters in
 
138
     * string-literals. Since 8.2, this depends on the value of the
 
139
     * <tt>standard_conforming_strings<tt> server variable.
 
140
     * 
 
141
     * @return true if the server treats string literals according to the SQL
 
142
     *   standard
 
143
     * 
 
144
     * @see ProtocolConnection#getStandardConformingStrings()
 
145
     */
 
146
    public boolean getStandardConformingStrings();
 
147
 
 
148
    // Ew. Quick hack to give access to the connection-specific utils implementation.
 
149
    public TimestampUtils getTimestampUtils();
 
150
 
 
151
    // Get the per-connection logger.
 
152
    public Logger getLogger();
 
153
 
 
154
    // Get the bind-string-as-varchar config flag
 
155
    public boolean getStringVarcharFlag();
 
156
 
 
157
    /**
 
158
     * Get the current transaction state of this connection.
 
159
     * 
 
160
     * @return a ProtocolConnection.TRANSACTION_* constant.
 
161
     */
 
162
    public int getTransactionState();
 
163
}