Parse SQL to sql builder
Another option, I've used JSQLParser in the past for a project like this. It wasn't very difficult to use.
jOOQ's Parser
jOOQ's more recent versions have introduced a parser, which parses arbitrary SQL from all currently supported vendor dialects into the jOOQ expression tree. Once you have that expression tree, you can manipulate it to whatever you want using the VisitListener
SPI.
For historic context:
For jOOQ, there exists a third-party contribution by Gudu Software called SQL 2 jOOQ, which can parse SQL SELECT
statements written in either MySQL or PostgreSQL dialects and generate jOOQ code as output.