1
/*****************************************************************************
2
* Copyright (C) 2008 EnterpriseDB Corporation.
3
* Copyright (C) 2011 Stado Global Development Group.
5
* This file is part of Stado.
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.
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.
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/>.
20
* You can find Stado at http://www.stado.us
22
****************************************************************************/
23
package org.postgresql.driver.core;
27
import org.postgresql.driver.PGConnection;
28
import org.postgresql.driver.jdbc2.TimestampUtils;
31
* Driver-internal connection interface. Application code should not use
34
public interface BaseConnection extends PGConnection, Connection
37
* Cancel the current query executing on this connection.
39
* @throws SQLException if something goes wrong.
41
public void cancelQuery() throws SQLException;
44
* Execute a SQL query that returns a single resultset.
45
* Never causes a new transaction to be started regardless of the autocommit setting.
47
* @param s the query to execute
48
* @return the (non-null) returned resultset
49
* @throws SQLException if something goes wrong.
51
public ResultSet execSQLQuery(String s) throws SQLException;
53
public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException;
56
* Execute a SQL query that does not return results.
57
* Never causes a new transaction to be started regardless of the autocommit setting.
59
* @param s the query to execute
60
* @throws SQLException if something goes wrong.
62
public void execSQLUpdate(String s) throws SQLException;
65
* Get the QueryExecutor implementation for this connection.
67
* @return the (non-null) executor
69
public QueryExecutor getQueryExecutor();
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)}.
77
* If no class is registered as handling the given type, then a generic
78
* {@link org.postgresql.driver.util.PGobject} instance is returned.
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
85
public Object getObject(String type, String value) throws SQLException;
87
public Encoding getEncoding() throws SQLException;
89
public TypeInfo getTypeInfo();
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.
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
100
public boolean haveMinimumCompatibleVersion(String ver);
103
* Check if we have at least a particular server version.
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
109
public boolean haveMinimumServerVersion(String ver);
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).
117
* @param str the string to encode
118
* @return an encoded representation of the string
119
* @throws SQLException if something goes wrong.
121
public byte[] encodeString(String str) throws SQLException;
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()}.
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
132
public String escapeString(String str) throws SQLException;
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.
141
* @return true if the server treats string literals according to the SQL
144
* @see ProtocolConnection#getStandardConformingStrings()
146
public boolean getStandardConformingStrings();
148
// Ew. Quick hack to give access to the connection-specific utils implementation.
149
public TimestampUtils getTimestampUtils();
151
// Get the per-connection logger.
152
public Logger getLogger();
154
// Get the bind-string-as-varchar config flag
155
public boolean getStringVarcharFlag();
158
* Get the current transaction state of this connection.
160
* @return a ProtocolConnection.TRANSACTION_* constant.
162
public int getTransactionState();