2
* HA-JDBC: High-Availability JDBC
3
* Copyright (c) 2004-2007 Paul Ferraro
5
* This library is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU Lesser General Public License as published by the
7
* Free Software Foundation; either version 2.1 of the License, or (at your
8
* option) any later version.
10
* This library is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this library; if not, write to the Free Software Foundation,
17
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Contact: ferraro@users.sourceforge.net
21
package net.sf.hajdbc.sql;
23
import java.sql.Array;
25
import java.sql.CallableStatement;
27
import java.sql.Connection;
28
import java.sql.DatabaseMetaData;
29
import java.sql.NClob;
30
import java.sql.PreparedStatement;
31
import java.sql.ResultSet;
32
import java.sql.RowIdLifetime;
33
import java.sql.SQLWarning;
34
import java.sql.SQLXML;
35
import java.sql.Savepoint;
36
import java.sql.Statement;
37
import java.sql.Struct;
39
import java.util.Properties;
41
import org.easymock.EasyMock;
44
* Mock connection that creates mock statements
45
* @author Paul Ferraro
48
public class MockConnection implements Connection
51
* @see java.sql.Connection#createStatement()
53
public Statement createStatement()
55
return EasyMock.createMock(Statement.class);
59
* @see java.sql.Connection#prepareStatement(java.lang.String)
61
public PreparedStatement prepareStatement(String arg0)
67
* @see java.sql.Connection#prepareCall(java.lang.String)
69
public CallableStatement prepareCall(String arg0)
75
* @see java.sql.Connection#nativeSQL(java.lang.String)
77
public String nativeSQL(String arg0)
83
* @see java.sql.Connection#setAutoCommit(boolean)
85
public void setAutoCommit(boolean arg0)
90
* @see java.sql.Connection#getAutoCommit()
92
public boolean getAutoCommit()
98
* @see java.sql.Connection#commit()
105
* @see java.sql.Connection#rollback()
107
public void rollback()
112
* @see java.sql.Connection#close()
119
* @see java.sql.Connection#isClosed()
121
public boolean isClosed()
127
* @see java.sql.Connection#getMetaData()
129
public DatabaseMetaData getMetaData()
131
return new DatabaseMetaData()
134
public boolean allProceduresAreCallable()
139
public boolean allTablesAreSelectable()
144
public String getURL()
149
public String getUserName()
154
public boolean isReadOnly()
159
public boolean nullsAreSortedHigh()
164
public boolean nullsAreSortedLow()
169
public boolean nullsAreSortedAtStart()
174
public boolean nullsAreSortedAtEnd()
179
public String getDatabaseProductName()
184
public String getDatabaseProductVersion()
189
public String getDriverName()
194
public String getDriverVersion()
199
public int getDriverMajorVersion()
204
public int getDriverMinorVersion()
209
public boolean usesLocalFiles()
214
public boolean usesLocalFilePerTable()
219
public boolean supportsMixedCaseIdentifiers()
224
public boolean storesUpperCaseIdentifiers()
229
public boolean storesLowerCaseIdentifiers()
234
public boolean storesMixedCaseIdentifiers()
239
public boolean supportsMixedCaseQuotedIdentifiers()
244
public boolean storesUpperCaseQuotedIdentifiers()
249
public boolean storesLowerCaseQuotedIdentifiers()
254
public boolean storesMixedCaseQuotedIdentifiers()
259
public String getIdentifierQuoteString()
264
public String getSQLKeywords()
266
return ""; //$NON-NLS-1$
269
public String getNumericFunctions()
274
public String getStringFunctions()
279
public String getSystemFunctions()
284
public String getTimeDateFunctions()
289
public String getSearchStringEscape()
294
public String getExtraNameCharacters()
296
return ""; //$NON-NLS-1$
299
public boolean supportsAlterTableWithAddColumn()
304
public boolean supportsAlterTableWithDropColumn()
309
public boolean supportsColumnAliasing()
314
public boolean nullPlusNonNullIsNull()
319
public boolean supportsConvert()
324
public boolean supportsConvert(int fromType, int toType)
329
public boolean supportsTableCorrelationNames()
334
public boolean supportsDifferentTableCorrelationNames()
339
public boolean supportsExpressionsInOrderBy()
344
public boolean supportsOrderByUnrelated()
349
public boolean supportsGroupBy()
354
public boolean supportsGroupByUnrelated()
359
public boolean supportsGroupByBeyondSelect()
364
public boolean supportsLikeEscapeClause()
369
public boolean supportsMultipleResultSets()
374
public boolean supportsMultipleTransactions()
379
public boolean supportsNonNullableColumns()
384
public boolean supportsMinimumSQLGrammar()
389
public boolean supportsCoreSQLGrammar()
394
public boolean supportsExtendedSQLGrammar()
399
public boolean supportsANSI92EntryLevelSQL()
404
public boolean supportsANSI92IntermediateSQL()
409
public boolean supportsANSI92FullSQL()
414
public boolean supportsIntegrityEnhancementFacility()
419
public boolean supportsOuterJoins()
424
public boolean supportsFullOuterJoins()
429
public boolean supportsLimitedOuterJoins()
434
public String getSchemaTerm()
439
public String getProcedureTerm()
444
public String getCatalogTerm()
449
public boolean isCatalogAtStart()
454
public String getCatalogSeparator()
459
public boolean supportsSchemasInDataManipulation()
464
public boolean supportsSchemasInProcedureCalls()
469
public boolean supportsSchemasInTableDefinitions()
474
public boolean supportsSchemasInIndexDefinitions()
479
public boolean supportsSchemasInPrivilegeDefinitions()
484
public boolean supportsCatalogsInDataManipulation()
489
public boolean supportsCatalogsInProcedureCalls()
494
public boolean supportsCatalogsInTableDefinitions()
499
public boolean supportsCatalogsInIndexDefinitions()
504
public boolean supportsCatalogsInPrivilegeDefinitions()
509
public boolean supportsPositionedDelete()
514
public boolean supportsPositionedUpdate()
519
public boolean supportsSelectForUpdate()
524
public boolean supportsStoredProcedures()
529
public boolean supportsSubqueriesInComparisons()
534
public boolean supportsSubqueriesInExists()
539
public boolean supportsSubqueriesInIns()
544
public boolean supportsSubqueriesInQuantifieds()
549
public boolean supportsCorrelatedSubqueries()
554
public boolean supportsUnion()
559
public boolean supportsUnionAll()
564
public boolean supportsOpenCursorsAcrossCommit()
569
public boolean supportsOpenCursorsAcrossRollback()
574
public boolean supportsOpenStatementsAcrossCommit()
579
public boolean supportsOpenStatementsAcrossRollback()
584
public int getMaxBinaryLiteralLength()
589
public int getMaxCharLiteralLength()
594
public int getMaxColumnNameLength()
599
public int getMaxColumnsInGroupBy()
604
public int getMaxColumnsInIndex()
609
public int getMaxColumnsInOrderBy()
614
public int getMaxColumnsInSelect()
619
public int getMaxColumnsInTable()
624
public int getMaxConnections()
629
public int getMaxCursorNameLength()
634
public int getMaxIndexLength()
639
public int getMaxSchemaNameLength()
644
public int getMaxProcedureNameLength()
649
public int getMaxCatalogNameLength()
654
public int getMaxRowSize()
659
public boolean doesMaxRowSizeIncludeBlobs()
664
public int getMaxStatementLength()
669
public int getMaxStatements()
674
public int getMaxTableNameLength()
679
public int getMaxTablesInSelect()
684
public int getMaxUserNameLength()
689
public int getDefaultTransactionIsolation()
694
public boolean supportsTransactions()
699
public boolean supportsTransactionIsolationLevel(int level)
704
public boolean supportsDataDefinitionAndDataManipulationTransactions()
709
public boolean supportsDataManipulationTransactionsOnly()
714
public boolean dataDefinitionCausesTransactionCommit()
719
public boolean dataDefinitionIgnoredInTransactions()
724
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern)
729
public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern)
734
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
739
public ResultSet getSchemas()
744
public ResultSet getCatalogs()
749
public ResultSet getTableTypes()
754
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
759
public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)
764
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern)
769
public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)
774
public ResultSet getVersionColumns(String catalog, String schema, String table)
779
public ResultSet getPrimaryKeys(String catalog, String schema, String table)
784
public ResultSet getImportedKeys(String catalog, String schema, String table)
789
public ResultSet getExportedKeys(String catalog, String schema, String table)
794
public ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable)
799
public ResultSet getTypeInfo()
804
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)
809
public boolean supportsResultSetType(int type)
814
public boolean supportsResultSetConcurrency(int type, int concurrency)
819
public boolean ownUpdatesAreVisible(int type)
824
public boolean ownDeletesAreVisible(int type)
829
public boolean ownInsertsAreVisible(int type)
834
public boolean othersUpdatesAreVisible(int type)
839
public boolean othersDeletesAreVisible(int type)
844
public boolean othersInsertsAreVisible(int type)
849
public boolean updatesAreDetected(int type)
854
public boolean deletesAreDetected(int type)
859
public boolean insertsAreDetected(int type)
864
public boolean supportsBatchUpdates()
869
public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types)
874
public Connection getConnection()
879
public boolean supportsSavepoints()
884
public boolean supportsNamedParameters()
889
public boolean supportsMultipleOpenResults()
894
public boolean supportsGetGeneratedKeys()
899
public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern)
904
public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern)
909
public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern)
914
public boolean supportsResultSetHoldability(int holdability)
919
public int getResultSetHoldability()
924
public int getDatabaseMajorVersion()
929
public int getDatabaseMinorVersion()
934
public int getJDBCMajorVersion()
939
public int getJDBCMinorVersion()
944
public int getSQLStateType()
949
public boolean locatorsUpdateCopy()
954
public boolean supportsStatementPooling()
960
public boolean autoCommitFailureClosesAllResultSets()
966
public ResultSet getClientInfoProperties()
972
public ResultSet getFunctionColumns(String arg0, String arg1, String arg2, String arg3)
978
public ResultSet getFunctions(String arg0, String arg1, String arg2)
984
public RowIdLifetime getRowIdLifetime()
990
public ResultSet getSchemas(String arg0, String arg1)
996
public boolean supportsStoredFunctionsUsingCallSyntax()
1002
public boolean isWrapperFor(Class<?> arg0)
1008
public <T> T unwrap(Class<T> arg0)
1017
* @see java.sql.Connection#setReadOnly(boolean)
1019
public void setReadOnly(boolean arg0)
1024
* @see java.sql.Connection#isReadOnly()
1026
public boolean isReadOnly()
1032
* @see java.sql.Connection#setCatalog(java.lang.String)
1034
public void setCatalog(String arg0)
1039
* @see java.sql.Connection#getCatalog()
1041
public String getCatalog()
1047
* @see java.sql.Connection#setTransactionIsolation(int)
1049
public void setTransactionIsolation(int arg0)
1054
* @see java.sql.Connection#getTransactionIsolation()
1056
public int getTransactionIsolation()
1062
* @see java.sql.Connection#getWarnings()
1064
public SQLWarning getWarnings()
1070
* @see java.sql.Connection#clearWarnings()
1072
public void clearWarnings()
1077
* @see java.sql.Connection#createStatement(int, int)
1079
public Statement createStatement(int arg0, int arg1)
1085
* @see java.sql.Connection#prepareStatement(java.lang.String, int, int)
1087
public PreparedStatement prepareStatement(String arg0, int arg1, int arg2)
1093
* @see java.sql.Connection#prepareCall(java.lang.String, int, int)
1095
public CallableStatement prepareCall(String arg0, int arg1, int arg2)
1101
* @see java.sql.Connection#getTypeMap()
1103
public Map<String, Class<?>> getTypeMap()
1109
* @see java.sql.Connection#setHoldability(int)
1111
public void setHoldability(int arg0)
1116
* @see java.sql.Connection#getHoldability()
1118
public int getHoldability()
1124
* @see java.sql.Connection#setSavepoint()
1126
public Savepoint setSavepoint()
1132
* @see java.sql.Connection#setSavepoint(java.lang.String)
1134
public Savepoint setSavepoint(String arg0)
1140
* @see java.sql.Connection#rollback(java.sql.Savepoint)
1142
public void rollback(Savepoint arg0)
1147
* @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)
1149
public void releaseSavepoint(Savepoint arg0)
1154
* @see java.sql.Connection#createStatement(int, int, int)
1156
public Statement createStatement(int arg0, int arg1, int arg2)
1162
* @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int)
1164
public PreparedStatement prepareStatement(String arg0, int arg1, int arg2, int arg3)
1170
* @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)
1172
public CallableStatement prepareCall(String arg0, int arg1, int arg2, int arg3)
1178
* @see java.sql.Connection#prepareStatement(java.lang.String, int)
1180
public PreparedStatement prepareStatement(String arg0, int arg1)
1186
* @see java.sql.Connection#prepareStatement(java.lang.String, int[])
1188
public PreparedStatement prepareStatement(String arg0, int[] arg1)
1194
* @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])
1196
public PreparedStatement prepareStatement(String arg0, String[] arg1)
1202
* @see java.sql.Connection#createArrayOf(java.lang.String, java.lang.Object[])
1205
public Array createArrayOf(String arg0, Object[] arg1)
1211
* @see java.sql.Connection#createBlob()
1214
public Blob createBlob()
1220
* @see java.sql.Connection#createClob()
1223
public Clob createClob()
1229
* @see java.sql.Connection#createNClob()
1232
public NClob createNClob()
1238
* @see java.sql.Connection#createSQLXML()
1241
public SQLXML createSQLXML()
1247
* @see java.sql.Connection#createStruct(java.lang.String, java.lang.Object[])
1250
public Struct createStruct(String arg0, Object[] arg1)
1256
* @see java.sql.Connection#getClientInfo()
1259
public Properties getClientInfo()
1265
* @see java.sql.Connection#getClientInfo(java.lang.String)
1268
public String getClientInfo(String arg0)
1274
* @see java.sql.Connection#isValid(int)
1277
public boolean isValid(int arg0)
1283
* @see java.sql.Connection#setClientInfo(java.util.Properties)
1286
public void setClientInfo(Properties arg0)
1291
* @see java.sql.Connection#setClientInfo(java.lang.String, java.lang.String)
1294
public void setClientInfo(String arg0, String arg1)
1299
* @see java.sql.Connection#setTypeMap(java.util.Map)
1302
public void setTypeMap(Map<String, Class<?>> arg0)
1307
* @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
1310
public boolean isWrapperFor(Class<?> arg0)
1316
* @see java.sql.Wrapper#unwrap(java.lang.Class)
1319
public <T> T unwrap(Class<T> arg0)