permaculture playing cards*
The moose likes JDBC and the fly likes Read and Write .sql files using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Read and Write .sql files using java" Watch "Read and Write .sql files using java" New topic
Author

Read and Write .sql files using java

Manju Krishna
Ranch Hand

Joined: Apr 09, 2009
Posts: 48
    
    1
I want to know if there are any freeware's available to read and write .sql files. I hava a .sql file with set of insert statements and I need to identify the values that are pushed into table, the table name, the inner query clauses etc., from the sql statement.

After identifying, need to translate and push those changes back to the .sql file. Is there any way to do this with help of parsers rather reading the whole of file line by line.

I did come across few parsers like ZQL, sqljep etc., but could not really solve the issue. Please help..
Thanks in advance.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Is this a one-time use for yourself or part of an application you need to build? Stuff like this is often easier to write yourself in Java assuming the kinds of changes you need to be make can be made with regular expressions and the files you are reading are highly structured. The issue with 'generic' read/write tools is that every database has its own unique flavor of SQL and not all of them exactly match each other even on some basic commands.


My Blog: Down Home Country Coding with Scott Selikoff
Manju Krishna
Ranch Hand

Joined: Apr 09, 2009
Posts: 48
    
    1
Say I have a line like below,


These statements gets repeated in the file consecutively. I need to get the insert column values (like user_id, module_id etc.,) and values that are inserted into the table (like 'LANGUAGE', 'L','system_preferences' etc., ) into any data structure. And also replace the values with translated values in same positions in writing back the values.
 
Consider Paul's rocket mass heater.
 
subject: Read and Write .sql files using java
 
Similar Threads
i need to read files with dateformat filename from a folder
how to write properties file
How to pass BLOB to a PL/SQL Stored Procedure
Xalan and line by line parsing
Meaning of XML