Java Doc for SQLDeArger.java in  » Profiler » JAMon » com » jamonapi » proxy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Profiler » JAMon » com.jamonapi.proxy 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jamonapi.proxy.SQLDeArger

SQLDeArger
public class SQLDeArger (Code)
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.
author:
   steve souza



Constructor Summary
public  SQLDeArger(String sql)
    
public  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.

Method Summary
public  voidaddMatchString(String matchString)
    
 String[][]getAll()
     Return an array that has 1) all sql, 2) the sql type, 3) the parsed sql, 4) any matched strings if they exist.
public  String[]getMatches()
     Returns an array of Strings that matched the Strings specified in the matches arraylist.
 intgetNumAll()
    
public  intgetNumMatches()
    
public  StringgetParsedSQL()
     Return sql with original argument values replaced with '?'.
public  StringgetSQLToParse()
     Get sql that was passed in to parse.
public  StringgetSQLType()
     Return the first word from the sql command.
public  booleanhasMatches()
    
public static  voidmain(String[] args)
     Method that has test code for this class.
public static  voidputSQLType(String type)
     SQL types are the first word that is in a sql statement.
 voidsetMatchStrings(List matchStrings)
     Note matchStrings should contain Strings.


Constructor Detail
SQLDeArger
public SQLDeArger(String sql)(Code)
Accepts string to parse



SQLDeArger
public SQLDeArger(String sql, List matchStrings)(Code)
Accepts strings to parse and a List of strings to check to see if they are in the sql statement. A good use for this is to pass table names into the constructor. After the constructor is called the sql will already have been parsed
Parameters:
  sql -
Parameters:
  matchStrings -




Method Detail
addMatchString
public void addMatchString(String matchString)(Code)
Add string to see if it matches in the query



getAll
String[][] getAll()(Code)
Return an array that has 1) all sql, 2) the sql type, 3) the parsed sql, 4) any matched strings if they exist. The array will be at least 2 long. This is useful to pass all the strings in the array to jamon to track stats associated with the query.



getMatches
public String[] getMatches()(Code)
Returns an array of Strings that matched the Strings specified in the matches arraylist. Note that the matches are performed after arg values have been replaced on the sql with '?'.



getNumAll
int getNumAll()(Code)
One for the statement, one for the keyword type of the statment, and the other numbers are for the matches



getNumMatches
public int getNumMatches()(Code)
Returns the number of matches or 0 if there were none



getParsedSQL
public String getParsedSQL()(Code)
Return sql with original argument values replaced with '?'. For example: select * from table where name=?



getSQLToParse
public String getSQLToParse()(Code)
Get sql that was passed in to parse.



getSQLType
public String getSQLType()(Code)
Return the first word from the sql command. These would include: select, update, delete, create, insert, commit,... If the word is not recognized then 'other' is returned.



hasMatches
public boolean hasMatches()(Code)
Returns true if there were any matches against the match Strings



main
public static void main(String[] args)(Code)
Method that has test code for this class. Click 'View Code' above to view the code



putSQLType
public static void putSQLType(String type)(Code)
SQL types are the first word that is in a sql statement. Examples are insert, delete, update, and select. However, any word that you add by calling this method will be detected as a sql type. Note the JDBCMonProxy uses this info to add a monitor for whenever a select, insert etc are executed. This gives the number of times and performances of the sql types. A list of all the default sql types follows: select, update, delete, insert, truncate, exec, create, drop, alter commit, rollback, grant, revoke, save. Any value that isn't on the list will return 'other'. The getSQLType method returns the SQL type value in the sql statement passed to the constructor.
Parameters:
  type -



setMatchStrings
void setMatchStrings(List matchStrings)(Code)
Note matchStrings should contain Strings. If it doesn't toString() will be called on the objects



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.