|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jamonapi.proxy.SQLDeArger
public class SQLDeArger
SQLDeArger takes a sql statement and 1) replaces argument values ('souza', "souza", 'souza''s', 100, 100.5, 0xff, 10e9) with question marks It makes full sql statements look more like a prepared statement. 2) Returns a sql type which is simply the first word of the command (typically 'select', 'update' etc. 3) Returns any specified keywords that are in the parsed sql. This is a good way to return table names. A normal sql statement with argument values would generate too much data for JAMon and wouldn't be very good for understanding how your query performed. Coneceptually the following queries are the same: 1) select * from table where name='steve', 2) select * from table where name='mindy'. However, if you passed both strings to jamon the 'sameness' wouldn't show up in the stats as each is a different string. However by putting question marks in place of the values this problem can be resolved (i.e. select * from table where name=?). One issue with the way this is done at this point is numbers or strings in other places can be replaced too. This shouldn't affect monitoring however. For example This "select abs(200) from table", would be parsed to "select abs(?) from table". However, numbers of the format 100.00, really are multiple tokens. And will appear in the returned strings as ?.?. The class name SQLDeArger refers to the fact that argument values are removed from SQL statements. This class is also useful for logging sql statements.
Constructor Summary | |
---|---|
SQLDeArger(java.lang.String sql)
Accepts string to parse |
|
SQLDeArger(java.lang.String sql,
java.util.List matchStrings)
Accepts strings to parse and a List of strings to check to see if they are in the sql statement. |
Method Summary | |
---|---|
void |
addMatchString(java.lang.String matchString)
Add string to see if it matches in the query |
java.lang.String[] |
getMatches()
Returns an array of Strings that matched the Strings specified in the matches arraylist. |
int |
getNumMatches()
Returns the number of matches or 0 if there were none |
java.lang.String |
getParsedSQL()
Return sql with original argument values replaced with '?'. |
java.lang.String |
getSQLToParse()
Get sql that was passed in to parse. |
java.lang.String |
getSQLType()
Return the first word from the sql command. |
boolean |
hasMatches()
Returns true if there were any matches against the match Strings |
static void |
main(java.lang.String[] args)
Method that has test code for this class. |
static void |
putSQLType(java.lang.String type)
SQL types are the first word that is in a sql statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SQLDeArger(java.lang.String sql)
public SQLDeArger(java.lang.String sql, java.util.List matchStrings)
sql
- matchStrings
- Method Detail |
---|
public java.lang.String getParsedSQL()
public java.lang.String getSQLToParse()
public java.lang.String getSQLType()
public java.lang.String[] getMatches()
public boolean hasMatches()
public int getNumMatches()
public void addMatchString(java.lang.String matchString)
public static void putSQLType(java.lang.String type)
type
- public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |