JSqlParser
JSqlParser copied to clipboard
Get fingerprint from a sql?
How to get the fingerprint from a specified sql? Is there any implemention in JSqlParser?
Greetings,
there is no specific implementation (because it is not really our concern), however you can safely create a distinct fingerprint by:
- parsing your SQL with JSQLParser
- de-parsing it (in order to mangle white space and Upper-/Lower-Case spelling)
- hashing it with your favorite algorithm (e. g. SHA-1)
First you need to specify what you mean by fingerprint. @manticore-projects suggestion is right, if all of your SQL is relevant. But you could also replace concrete values by a e.g. question mark and then
select * from mytable where id = 5
would by equal to
select * from mytable where id = 6
@wumpz is right of course: For the purpose of execution plans, when Deparsing, you could rewrite all Values
(String, Date, Double) with Parameters
, before you hash.
@roseduan Excuse me, have you solved the problem of obtaining fingerprints?
Closed, since no further question has been asked.