|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.jtds.jdbc.SQLParser
Process JDBC escape strings and parameter markers in the SQL string.
This code recognizes the following escapes:
Field Summary | |
private ConnectionJDBC2 |
connection
Connection object for server specific parsing. |
private static java.util.HashMap |
cvMap
Map of jdbc to server data types for convert |
private int |
d
Current position in output buffer. |
private static byte[] |
dateMask
Syntax mask for date escape. |
private static java.util.HashMap |
fnMap
Map of jdbc to sybase function names. |
private char[] |
in
Input buffer with SQL statement. |
private java.lang.String |
keyWord
First SQL keyword or identifier in statement. |
private int |
len
Length of input buffer. |
private static java.util.HashMap |
msFnMap
Map of jdbc to sql server function names. |
private char[] |
out
Output buffer to contain parsed SQL. |
private java.util.ArrayList |
params
Parameter list to be populated. |
private java.lang.String |
procName
Procedure name in call escape. |
private int |
s
Current position in input buffer. |
private java.lang.String |
tableName
First table name in from clause |
private char |
terminator
Current expected terminator character. |
private static byte[] |
timeMask
Syntax mask for time escape. |
(package private) static byte[] |
timestampMask
Syntax mask for timestamp escape. |
Constructor Summary | |
(package private) |
SQLParser(java.lang.String sql,
java.util.ArrayList paramList,
ConnectionJDBC2 connection)
Construct a new Parser object to process the supplied SQL. |
Method Summary | |
(package private) static void |
|
private void |
callEscape()
Process the JDBC {call procedure [(?,?,?)]} type escape. |
private java.lang.String |
copyKeyWord()
Copy over possible SQL keyword eg 'SELECT' |
private void |
copyLiteral(java.lang.String txt)
Insert a String literal in the output buffer. |
private void |
copyParam(java.lang.String name,
int pos)
Build a new parameter item. |
private java.lang.String |
copyParamName()
Copy an embedded parameter name to the output buffer. |
private java.lang.String |
copyProcName()
Copy an embedded stored procedure identifier over to the output buffer. |
private void |
copyString()
Copy over an embedded string literal unchanged. |
private void |
dateEscape()
Process the JDBC escape {d 'CCCC-MM-DD'}. |
private void |
escape()
Process the JDBC escape sequences. |
private void |
functionEscape()
Process the JDBC escape {fn function()}. |
private boolean |
getDateTimeField(byte[] mask)
Utility routine to validate date and time escapes. |
private java.lang.String |
getTableName()
Extract the first table name following the keyword FROM. |
private void |
likeEscape()
Process the JDBC escape {escape 'X'}. |
private void |
mustbe(char c,
boolean copy)
Check that the next character is as expected. |
private void |
outerJoinEscape()
Process the JDBC escape {oj left outer join etc}. |
(package private) java.lang.String[] |
parse(boolean extractTable)
Parse the SQL statement processing JDBC escapes and parameter markers. |
private void |
skipMultiComments()
Skip multi-line comments |
private void |
skipSingleComments()
Skip single-line comments. |
private void |
skipWhiteSpace()
Skip embedded white space. |
private void |
timeEscape()
Process the JDBC escape {t 'HH:MM:SS'}. |
private void |
timestampEscape()
Process the JDBC escape {ts 'CCCC-MM-DD HH:MM:SS[.NNN]'}. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Field Detail |
private char[] in
private int s
private int len
private char[] out
private int d
private java.util.ArrayList params
private char terminator
private java.lang.String procName
private java.lang.String keyWord
private java.lang.String tableName
private ConnectionJDBC2 connection
private static final byte[] timeMask
private static final byte[] dateMask
static final byte[] timestampMask
private static java.util.HashMap fnMap
private static java.util.HashMap msFnMap
private static java.util.HashMap cvMap
Constructor Detail |
SQLParser(java.lang.String sql, java.util.ArrayList paramList, ConnectionJDBC2 connection)
sql
- The SQL statement to parse.paramList
- The Parameter list array to populate.Method Detail |
private void copyLiteral(java.lang.String txt)
txt
- The text to insert.private void copyString()
private java.lang.String copyKeyWord()
private void copyParam(java.lang.String name, int pos)
name
- Optional parameter name or null.pos
- The parameter marker position in the output buffer.private java.lang.String copyProcName() throws java.sql.SQLException
String
.private java.lang.String copyParamName()
String
.private void mustbe(char c, boolean copy) throws java.sql.SQLException
c
- The expected character.copy
- True if found character should be copied.java.sql.SQLException
- if expected characeter not found.private void skipWhiteSpace()
private void skipSingleComments()
private void skipMultiComments()
private void callEscape() throws java.sql.SQLException
java.sql.SQLException
- private boolean getDateTimeField(byte[] mask)
mask
- The validation maskprivate void timeEscape() throws java.sql.SQLException
java.sql.SQLException
- private void dateEscape() throws java.sql.SQLException
java.sql.SQLException
- private void timestampEscape() throws java.sql.SQLException
java.sql.SQLException
- private void outerJoinEscape() throws java.sql.SQLException
java.sql.SQLException
- static void()
private void functionEscape() throws java.sql.SQLException
java.sql.SQLException
- private void likeEscape() throws java.sql.SQLException
java.sql.SQLException
- private void escape() throws java.sql.SQLException
java.sql.SQLException
- private java.lang.String getTableName()
String
java.lang.String[] parse(boolean extractTable) throws java.sql.SQLException
extractTable
- true to return the first table name in the FROM clause of a selectString[]
.java.sql.SQLException
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |