 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Smith Guest
|
Posted: Thu Jan 15, 2004 1:51 pm Post subject: SQL parsing library |
|
|
Good evening,
I'm hunting for an SQL parsing library. Specifically, the task I have
in mind is as follows: take an SQL query (which may already contain some
'?' characters for parameterized values), and replace ALL literal values
with the '?' character, while not touching anything else in the query.
I want to do this because I'm instrumenting a JDBC driver to provide
metrics on the frequency and average running time of queries in the
application, and I want to treat all queries of the same general form as
being identical to each other when counting frequency and average
running time.
Thanks in advance,
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
|
| Back to top |
|
 |
Robert Klemme Guest
|
Posted: Fri Jan 16, 2004 9:08 am Post subject: Re: SQL parsing library |
|
|
"Chris Smith" <cdsmith (AT) twu (DOT) net> schrieb im Newsbeitrag
news:MPG.1a7048b59068cf599898a8 (AT) news (DOT) pop4.net...
| Quote: | Good evening,
I'm hunting for an SQL parsing library. Specifically, the task I have
in mind is as follows: take an SQL query (which may already contain some
'?' characters for parameterized values), and replace ALL literal values
with the '?' character, while not touching anything else in the query.
I want to do this because I'm instrumenting a JDBC driver to provide
metrics on the frequency and average running time of queries in the
application, and I want to treat all queries of the same general form as
being identical to each other when counting frequency and average
running time.
|
It might be sufficient to come up with a regexp sophisticated enough.
Something along the lines of
/'[^']*'|[+-]?[0-9]+(.[0-9]+)?([eE][+-]?[0-9]+)?|[0-9]{4}-[0-9]{2}-[0-9]{
2}([0-9]{2}:[0-9]{2}(:[0-9]{2})?)?/
That should catch
- string literals
- numbers
- date / timestamp
Note: untested.
Not so simple though... :-}
robert
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|