Looking for an embeddable SQL beautifier or reformatter

I am looking for a Java open source beautifier or reformatter for SQL that I can use to clean up DDL statements that I am generating with openArchitectureWare.

Nothing in the answer to "Online Code Beautifier And Formatter" is of use to me and I have not been able to get Simple SQL Formatter to work for me.

Answers


UPDATE 2: org.hibernate.jdbc.util.BasicFormatterImpl got moved in release 4.0. It is now located at: org.hibernate.engine.jdbc.internal.BasicFormatterImpl.

UPDATE: Technology marches on. As noted by Alex, org.hibernate.pretty.Formatter no longer exists as of version 3.3.2.GA. The replacement is org.hibernate.jdbc.util.BasicFormatterImpl:

String formattedSQL = new BasicFormatterImpl().format(sql);

At this writing, this answer has the most upvotes, and ought to have the current correct answer in it, so I have updated it accordingly. Props to Alex for bringing it up.

...

ORIGINAL ANSWER: If you're using Hibernate, they've got one built-in: org.hibernate.pretty.Formatter

String formattedSQL = new Formatter(sql).format();

Need Your Help

I need to change this searchforms code using this code?

php wordpress search

I have a search on the front of wordpress, it needs to be replaced with the second search which searches my gallery. I've tried messing with the codes but nothing is working?

Drawing view inside UIScrollView

objective-c cocoa-touch ios uiview uiscrollview

I have a view with which you can do finger drawing. It's currently in UIScrollView. Although it can draw, it is very buggy because while I am drawing, the ScrollView scrolls up and down, so how can I

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.