jadkachmar
jadkachmar

Reputation: 118

SQL script to XML format

one major requirement in my java application is to store sql queries on databases to be used later on. Since my application connects to different database types like MSSQL, HSQL, Oracle ... etc, and since each type has its own sql script format, I need a parser/converter to parse my sql script to one uniform language (XML) and the other way around.

so when storing a script like 'SELECT * FROM [Project].[dbo].tableName' (MSSQL) it would be parsed to lets say:

<Select>
<fields>*</fields>
<tableSource>tableName</tableSource> 

My question is that is there a present free downloadable converter to be used for this task which supports different types of DB syntax, or if not which is the most efficient way to implement this parser to be able to cover most of the syntax.

Upvotes: 0

Views: 264

Answers (1)

Hu Bin
Hu Bin

Reputation: 459

What about use this structure

<sqls>
<sql>
<db-type name="mysql" />
<sql-query><[CDTATA[select * form .....]]></sql-query>
</sql>
<sql>
<db-type name="oracle" />
<sql-query><[CDTATA[select * form .....]]></sql-query>
</sql>
<sqls>

Upvotes: 1

Related Questions