~ubuntu-branches/ubuntu/maverick/libpgjava/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-25 00:07:07 UTC
  • mfrom: (1.3.1 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060425000707-6lr2s0awuz4z48hm
* Drop support for the old jdbc2 driver (can be reverted if wanted)
  (closes: #358345).
* New upstream (thanks to Wolfgang Baer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
*
 
3
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
 
4
*
 
5
* IDENTIFICATION
 
6
*   $PostgreSQL: pgjdbc/org/postgresql/core/BaseConnection.java,v 1.15 2005/08/01 06:54:14 oliver Exp $
 
7
*
 
8
*-------------------------------------------------------------------------
 
9
*/
 
10
package org.postgresql.core;
 
11
 
 
12
import java.sql.*;
 
13
import org.postgresql.PGConnection;
 
14
import org.postgresql.jdbc2.TimestampUtils;
 
15
 
 
16
/**
 
17
 * Driver-internal connection interface. Application code should not use
 
18
 * this interface.
 
19
 */
 
20
public interface BaseConnection extends PGConnection, Connection
 
21
{
 
22
    /**
 
23
     * Cancel the current query executing on this connection.
 
24
     *
 
25
     * @throws SQLException if something goes wrong.
 
26
     */
 
27
    public void cancelQuery() throws SQLException;
 
28
 
 
29
    /**
 
30
     * Execute a SQL query that returns a single resultset.
 
31
     * Never causes a new transaction to be started regardless of the autocommit setting.
 
32
     *
 
33
     * @param s the query to execute
 
34
     * @return the (non-null) returned resultset
 
35
     * @throws SQLException if something goes wrong.
 
36
     */
 
37
    public ResultSet execSQLQuery(String s) throws SQLException;
 
38
 
 
39
    /**
 
40
     * Execute a SQL query that does not return results.
 
41
     * Never causes a new transaction to be started regardless of the autocommit setting.
 
42
     *
 
43
     * @param s the query to execute
 
44
     * @throws SQLException if something goes wrong.
 
45
     */
 
46
    public void execSQLUpdate(String s) throws SQLException;
 
47
 
 
48
    /**
 
49
     * Get the QueryExecutor implementation for this connection.
 
50
     *
 
51
     * @return the (non-null) executor
 
52
     */
 
53
    public QueryExecutor getQueryExecutor();
 
54
 
 
55
    /**
 
56
     * Construct and return an appropriate object for the given
 
57
     * type and value. This only considers the types registered via
 
58
     * {@link org.postgresql.PGConnection#addDataType(String,Class)} and
 
59
     * {@link org.postgresql.PGConnection#addDataType(String,String)}.
 
60
     *<p>
 
61
     * If no class is registered as handling the given type, then a generic
 
62
     * {@link org.postgresql.util.PGobject} instance is returned.
 
63
     *
 
64
     * @param type the backend typename
 
65
     * @param value the type-specific string representation of the value
 
66
     * @return an appropriate object; never null.
 
67
     * @throws SQLException if something goes wrong
 
68
     */
 
69
    public Object getObject(String type, String value) throws SQLException;
 
70
 
 
71
 
 
72
    public String getJavaClass(int oid) throws SQLException;
 
73
 
 
74
    /**
 
75
     * Look up the postgresql type name for a given oid. This is the
 
76
     * inverse of {@link #getPGType(String)}.
 
77
     *
 
78
     * @param oid the type's OID
 
79
     * @return the server type name for that OID, or null if unknown
 
80
     * @throws SQLException if something goes wrong
 
81
     */
 
82
    public String getPGType(int oid) throws SQLException;
 
83
 
 
84
    /**
 
85
     * Look up the oid for a given postgresql type name. This is the
 
86
     * inverse of {@link #getPGType(int)}.
 
87
     *
 
88
     * @param pgTypeName the server type name to look up
 
89
     * @return oid the type's OID, or 0 if unknown
 
90
     * @throws SQLException if something goes wrong
 
91
     */
 
92
    public int getPGType(String pgTypeName) throws SQLException;
 
93
 
 
94
    /**
 
95
     * Look up the SQL typecode for a given type oid.
 
96
     *
 
97
     * @param oid the type's OID
 
98
     * @return the SQL typecode (a constant from {@link java.sql.Types}) for the type
 
99
     * @throws SQLException if something goes wrong
 
100
     */
 
101
    public int getSQLType(int oid) throws SQLException;
 
102
 
 
103
    /**
 
104
     * Look up the SQL typecode for a given postgresql type name.
 
105
     *
 
106
     * @param pgTypeName the server type name to look up
 
107
     * @return the SQL typecode (a constant from {@link java.sql.Types}) for the type
 
108
     * @throws SQLException if something goes wrong
 
109
     */
 
110
    public int getSQLType(String pgTypeName) throws SQLException;
 
111
 
 
112
    /**
 
113
     * Check if we should use driver behaviour introduced in a particular
 
114
     * driver version. This defaults to behaving as the actual driver's version
 
115
     * but can be overridden by the "compatible" URL parameter.
 
116
     *
 
117
     * @param ver the driver version to check
 
118
     * @return true if the driver's behavioural version is at least "ver".
 
119
     * @throws SQLException if something goes wrong
 
120
     */
 
121
    public boolean haveMinimumCompatibleVersion(String ver);
 
122
 
 
123
    /**
 
124
     * Check if we have at least a particular server version.
 
125
     *
 
126
     * @param ver the server version to check
 
127
     * @return true if the server version is at least "ver".
 
128
     * @throws SQLException if something goes wrong
 
129
     */
 
130
    public boolean haveMinimumServerVersion(String ver);
 
131
 
 
132
    /**
 
133
     * Encode a string using the database's client_encoding
 
134
     * (usually UNICODE, but can vary on older server versions).
 
135
     * This is used when constructing synthetic resultsets (for
 
136
     * example, in metadata methods).
 
137
     *
 
138
     * @param str the string to encode
 
139
     * @return an encoded representation of the string
 
140
     * @throws SQException if something goes wrong.
 
141
     */
 
142
    public byte[] encodeString(String str) throws SQLException;
 
143
 
 
144
    // Ew. Quick hack to give access to the connection-specific utils implementation.
 
145
    public TimestampUtils getTimestampUtils();
 
146
}