I am looking for a simple library [free] wherein i can use something like this:-
String formattedSQL = xyzLib.format开发者_Python百科 ( 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>
精彩评论