I am looking for a simple library [free] wherein i can use something like this:-
String formattedSQL = xyzLib.format ( sql );
Is there any such library? Or is there a way to format the SQL?
I'm not aware of a library that does this, but you might look at Hibernate's SQL formatter. From my experience it does a pretty good job at prettifying SQL statements, but as always, it might not be exactly what you want.
Yohei Yamana (vertical-blank) has written an open source, pure-Java standalone, zero-dependencies SQL Formatter. It is available from maven central:
<dependency>
<groupId>com.github.vertical-blank</groupId>
<artifactId>sql-formatter</artifactId>
<version>1.0</version>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With