KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > sql > UnknownRequest


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Mathieu Peltier.
23  */

24
25 package org.objectweb.cjdbc.common.sql;
26
27 import java.io.IOException JavaDoc;
28 import java.io.Serializable JavaDoc;
29 import java.sql.SQLException JavaDoc;
30
31 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
32 import org.objectweb.cjdbc.common.stream.CJDBCInputStream;
33 import org.objectweb.cjdbc.common.stream.CJDBCOutputStream;
34
35 /**
36  * An <code>UnknownRequest</code> is an SQL request that does not match any
37  * SQL query known by this software.
38  *
39  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
40  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
41  * @version 1.0
42  */

43 public class UnknownRequest extends AbstractRequest implements Serializable JavaDoc
44 {
45   private static final long serialVersionUID = -1990341658455593552L;
46
47   /**
48    * Creates a new <code>UnknownRequest</code> instance.
49    *
50    * @param sqlQuery the SQL query
51    * @param escapeProcessing should the driver to escape processing before
52    * sending to the database?
53    * @param timeout an <code>int</code> value
54    * @param lineSeparator the line separator used in the query
55    */

56   public UnknownRequest(String JavaDoc sqlQuery, boolean escapeProcessing, int timeout,
57       String JavaDoc lineSeparator)
58   {
59     super(sqlQuery, escapeProcessing, timeout, lineSeparator,
60         RequestType.UNDEFINED);
61   }
62
63   /**
64    * @see AbstractRequest
65    */

66   public UnknownRequest(CJDBCInputStream in) throws IOException JavaDoc
67   {
68     super(in, RequestType.UNDEFINED);
69     receiveResultSetParams(in);
70   }
71
72   /**
73    * @see AbstractRequest
74    */

75   public void sendToStream(CJDBCOutputStream out, boolean needSqlSkeleton)
76       throws IOException JavaDoc
77   {
78     super.sendToStream(out, needSqlSkeleton);
79     sendResultSetParams(out);
80   }
81
82   /**
83    * @return <code>false</code>
84    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#needsMacroProcessing()
85    */

86   public boolean needsMacroProcessing()
87   {
88     return false;
89   }
90
91   /**
92    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#returnsResultSet()
93    */

94   public boolean returnsResultSet()
95   {
96     // this is the more cautious
97
return true;
98   }
99
100   /**
101    * Throws always an <code>SQLException</code>: it is not possible to parse
102    * an unknown request because we don't know its syntax or semantic.
103    *
104    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#parse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema,
105    * int, boolean)
106    */

107   public void parse(DatabaseSchema schema, int granularity,
108       boolean isCaseSensitive) throws SQLException JavaDoc
109   {
110     throw new SQLException JavaDoc("Unable to parse an unknown request");
111   }
112
113   /**
114    * Throws always an <code>SQLException</code>: it is not possible to parse
115    * an unknown request because we don't know its syntax or semantic.
116    *
117    * @see AbstractRequest#cloneParsing(AbstractRequest)
118    */

119   public void cloneParsing(AbstractRequest request)
120   {
121     throw new RuntimeException JavaDoc(
122         "Unable to clone the parsing of an unknown request");
123   }
124 }
Popular Tags