View Javadoc
1   /*
2    * $Source$
3    * $Revision$
4    *
5    * Copyright (C) 2008 Tim Pizey
6    *
7    * Part of Melati (http://melati.org), a framework for the rapid
8    * development of clean, maintainable web applications.
9    *
10   * Melati is free software; Permission is granted to copy, distribute
11   * and/or modify this software under the terms either:
12   *
13   * a) the GNU General Public License as published by the Free Software
14   *    Foundation; either version 2 of the License, or (at your option)
15   *    any later version,
16   *
17   *    or
18   *
19   * b) any version of the Melati Software License, as published
20   *    at http://melati.org
21   *
22   * You should have received a copy of the GNU General Public License and
23   * the Melati Software License along with this program;
24   * if not, write to the Free Software Foundation, Inc.,
25   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26   * GNU General Public License and visit http://melati.org to obtain the
27   * Melati Software License.
28   *
29   * Feel free to contact the Developers of Melati (http://melati.org),
30   * if you would like to work out a different arrangement than the options
31   * outlined here.  It is our intention to allow Melati to be used by as
32   * wide an audience as possible.
33   *
34   * This program is distributed in the hope that it will be useful,
35   * but WITHOUT ANY WARRANTY; without even the implied warranty of
36   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37   * GNU General Public License for more details.
38   *
39   * Contact details for copyright holder:
40   *
41   *     Tim Pizey <timp At paneris.org>
42   *     http://paneris.org/~timp
43   */
44  
45  package org.melati.poem.dbms.test.sql;
46  
47  import java.sql.DatabaseMetaData;
48  import java.sql.ResultSet;
49  import java.sql.RowIdLifetime;
50  import java.sql.SQLException;
51  
52  /**
53   * The JDBC4 members of a {@link DatabaseMetaData}, decorated to throw an SQLException on command.
54   * 
55   * @author timp
56   * @since  5 Feb 2008
57   *
58   */
59  public abstract class ThrowingDatabaseMetaDataJdbc4 
60      extends ThrowingDatabaseMetaDataJdbc3 
61      implements DatabaseMetaData {
62    
63    /**
64     *  JDBC 4.0
65     */
66    
67   
68    /** 
69     * {@inheritDoc}
70     * @see java.sql.DatabaseMetaData#autoCommitFailureClosesAllResultSets()
71     */
72    public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
73      if (shouldThrow(this.getClass().getInterfaces()[0], "autoCommitFailureClosesAllResultSets"))
74        throw new SQLException("DatabaseMetaData bombed");
75      return it.autoCommitFailureClosesAllResultSets();
76    }
77    /** 
78     * {@inheritDoc}
79     * @see java.sql.DatabaseMetaData#getClientInfoProperties()
80     */
81    public ResultSet getClientInfoProperties() throws SQLException {
82      if (shouldThrow(this.getClass().getInterfaces()[0], "getClientInfoProperties"))
83        throw new SQLException("DatabaseMetaData bombed");
84      return new ThrowingResultSet(it.getClientInfoProperties());
85    }
86    /** 
87     * {@inheritDoc}
88     * @see java.sql.DatabaseMetaData#getFunctionColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
89     */
90    public ResultSet getFunctionColumns(String catalog, String schemaPattern,
91            String functionNamePattern, String columnNamePattern)
92            throws SQLException {
93      if (shouldThrow(this.getClass().getInterfaces()[0], "getFunctionColumns"))
94        throw new SQLException("DatabaseMetaData bombed");
95      return  new ThrowingResultSet(it.getFunctionColumns(catalog, schemaPattern, functionNamePattern, catalog));
96    }
97    /** 
98     * {@inheritDoc}
99     * @see java.sql.DatabaseMetaData#getFunctions(java.lang.String, java.lang.String, java.lang.String)
100    */
101   public ResultSet getFunctions(String catalog, String schemaPattern,
102           String functionNamePattern) throws SQLException {
103     if (shouldThrow(this.getClass().getInterfaces()[0], "getFunctions"))
104       throw new SQLException("DatabaseMetaData bombed");
105     return  new ThrowingResultSet(it.getFunctions(catalog, schemaPattern, functionNamePattern));
106   }
107   /** 
108    * {@inheritDoc}
109    * @see java.sql.DatabaseMetaData#getRowIdLifetime()
110    */
111   public RowIdLifetime getRowIdLifetime() throws SQLException {
112     if (shouldThrow(this.getClass().getInterfaces()[0], "getRowIdLifetime"))
113       throw new SQLException("DatabaseMetaData bombed");
114     return it.getRowIdLifetime();
115   }
116   /** 
117    * {@inheritDoc}
118    * @see java.sql.DatabaseMetaData#getSchemas(java.lang.String, java.lang.String)
119    */
120   public ResultSet getSchemas(String catalog, String schemaPattern)
121           throws SQLException {
122     if (shouldThrow(this.getClass().getInterfaces()[0], "getSchemas"))
123       throw new SQLException("DatabaseMetaData bombed");
124     return  new ThrowingResultSet(it.getSchemas());
125   }
126   /** 
127    * {@inheritDoc}
128    * @see java.sql.DatabaseMetaData#supportsStoredFunctionsUsingCallSyntax()
129    */
130   public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
131     if (shouldThrow(this.getClass().getInterfaces()[0], "supportsStoredFunctionsUsingCallSyntax"))
132       throw new SQLException("DatabaseMetaData bombed");
133     return it.supportsStoredFunctionsUsingCallSyntax();
134   }
135   /** 
136    * {@inheritDoc}
137    * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
138    */
139   public boolean isWrapperFor(Class<?> iface) throws SQLException {
140     if (shouldThrow(this.getClass().getInterfaces()[0], "isWrapperFor"))
141       throw new SQLException("DatabaseMetaData bombed");
142     return it.isWrapperFor(iface);
143   }
144   /** 
145    * {@inheritDoc}
146    * @see java.sql.Wrapper#unwrap(java.lang.Class)
147    */
148   public <T> T unwrap(Class<T> iface) throws SQLException {
149     if (shouldThrow(this.getClass().getInterfaces()[0], "unwrap"))
150       throw new SQLException("DatabaseMetaData bombed");
151     return it.unwrap(iface);
152   }
153   
154 
155 
156 }