public class SQLDeArger extends Object
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 and Description |
---|
SQLDeArger(String sql)
Accepts string to parse
|
SQLDeArger(String sql,
List matchStrings)
Accepts strings to parse and a List of strings to check to see if they are in the sql statement.
|
SQLDeArger(String sql,
List matchStrings,
int sqlMaxSize)
This constructor will truncate any sql statements longer than sqlMaxSize before the JAMon label is created
|
Modifier and Type | Method and Description |
---|---|
void |
addMatchString(String matchString)
Add string to see if it matches in the query
|
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
|
String |
getParsedSQL()
Return sql with original argument values replaced with '?'.
|
String |
getSQLToParse()
Get sql that was passed in to parse.
|
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 |
putSQLType(String type)
SQL types are the first word that is in a sql statement.
|
public SQLDeArger(String sql)
public SQLDeArger(String sql, List matchStrings)
sql
- matchStrings
- public String getParsedSQL()
public String getSQLToParse()
public String getSQLType()
public String[] getMatches()
public boolean hasMatches()
public int getNumMatches()
public void addMatchString(String matchString)
public static void putSQLType(String type)
type
- Copyright © 2015. All rights reserved.