//============================================================================== // FakeStatement.java //============================================================================== package tribble.sql.test; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import tribble.sql.StatementAdapter; /******************************************************************************* * Fake JDBC statement driver class. * * *
* Copyright ©2008 by David R. Tribble, all rights reserved.
* Permission is granted to any person or entity except those designated by
* by the United States Department of State as a terrorist, or terrorist
* government or agency, to use and distribute this source code provided
* that the original copyright notice remains present and unaltered.
*
* @see Test1
* @see FakeConnection
* @see FakeResultSet
*/
class FakeStatement
extends tribble.sql.StatementAdapter
{
static final String REV =
"@(#)tribble/sql/test/FakeStatement.java $Revision: 1.3 $ $Date: 2008/09/06 18:42:29 $\n";
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// Constructors
/***************************************************************************
* Constructor.
*
* @since 1.2, 2008-09-02
*/
FakeStatement(Connection conn)
{
super(conn);
}
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// Methods
/***************************************************************************
* Execute an SQL query.
*
* @param stmt
* A JDBC statement with which to execute the SQL query.
*
* @return
* The result set of the query if it was successful, otherwise an exception
* is thrown.
*
* @since 1.1, 2008-09-02
*/
public ResultSet executeQuery(String stmt)
throws SQLException
{
ResultSet res;
// Sanity check
if (stmt == null || stmt.length() == 0)
throw new SQLException("Missing query");
// Display the query
System.out.println("$ query: " + stmt);
// Build a result set
res = new FakeResultSet(stmt);
return res;
}
}
// End FakeStatement.java