00001
00025
package org.objectweb.cjdbc.common.sql;
00026
00027
import java.sql.SQLException;
00028
00029
import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
00030
00043 public class StoredProcedure extends AbstractRequest
00044 {
00045 private transient String
procedureName = null;
00046
00057 public StoredProcedure(String sqlQuery,
boolean escapeProcessing,
00058
int timeout, String lineSeparator)
00059 {
00060 super(sqlQuery, escapeProcessing, timeout, lineSeparator);
00061 cacheable =
RequestType.UNCACHEABLE;
00062 isParsed =
false;
00063 }
00064
00069 public boolean isReadRequest()
00070 {
00071
return false;
00072 }
00073
00078 public boolean isWriteRequest()
00079 {
00080
return false;
00081 }
00082
00087 public boolean isUnknownRequest()
00088 {
00089
return true;
00090 }
00091
00097 public String
getProcedureName()
00098 {
00099
if (
procedureName == null)
00100
try
00101 {
00102
parse(null, 0,
true);
00103 }
00104
catch (SQLException e)
00105 {
00106
return null;
00107 }
00108
return procedureName;
00109 }
00110
00117 public void parse(
DatabaseSchema schema,
int granularity,
00118
boolean isCaseSensitive)
throws SQLException
00119 {
00120 sqlQuery = sqlQuery.trim();
00121
if (sqlQuery.length() < 6)
00122
throw new SQLException(
"Malformed stored procedure call '" + sqlQuery
00123 +
"'");
00124
00125
int parenthesis = sqlQuery.indexOf(
'(');
00126
if (parenthesis == -1)
00127
procedureName = sqlQuery.substring(5);
00128
else
00129
procedureName = sqlQuery.substring(5, parenthesis);
00130
00131
procedureName =
procedureName.trim();
00132 }
00133
00141 public void cloneParsing(
AbstractRequest request)
00142 {
00143
throw new RuntimeException(
00144
"Unable to clone the parsing of a stored procedure call");
00145 }
00146
00147 }