For my current project I need a SQL parser that parses Oracle SQL statements. Currently I\'ve been using jsqlparser, which worked well for simple queries. But when specific
After working the same issue, I managed to get a SQL parser working:
My code looks like this:
import oracle.jdeveloper.db.DatabaseConnections;
import oracle.javatools.db.sql.SQLQueryBuilder;
import oracle.javatools.db.Database;
...
// load the database connections
// this is specific to Oracle SQL developer
DatabaseConnections connections = DatabaseConnections.getPrivateInstance(
(new File("src/test/resources/connection.xml")).toURI().toURL(),
"somePassword");
// get the one we are interested in
Database database = connections.getDatabase("the-name-of-a-sqldeveloper-connection");
SQLQueryBuilder queryBuilder = SQLQueryBuilderFactory.createBuilder(
database, new Schema("OPTIONAL_SCHEMA"), "select * from some_table");
The challenges to get this working are:
HSx10FtlsPc=
thin
...
To get such a file you will need to dig into the folder where Oracle SQL Developer settings are stored and just copy-paste that content into your own file.
Now, assuming you managed to get this far here are the problems and the points where I got disappointed by the end solution:
The reason I posted this answer is to drive community attention to the fact that having an Oracle SQL parser is perfectly feasible and maybe one day Oracle will consider exposing the parser as a competitive advantage (I am sure there are users out there that would happily pay some fees to get a license).