Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Dynamically inserting data into text files

Options
  • 19-04-2005 10:04am
    #1
    Closed Accounts Posts: 1,525 ✭✭✭


    Just wondering if there is some easy way of doing this in java.
    Say you already have a text file with parameters mentioned in the text
    e.g.
    select #firstName# from #tableName#;

    Is there some way to dynamically add the firstName and tableName parameters and to write out a new text file containing the values?
    Thanks for any help.


Comments

  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    You mean a JDBC driver for CSV files?
    http://csvjdbc.sourceforge.net/


  • Closed Accounts Posts: 1,525 ✭✭✭vorbis


    Thanks for the reply. its not a csv file though. I didn't really give a good example
    Rather its a sql script containing a number of sql statements.

    Hopefully this is a better example
    e.g. insertPurchase.sql
    insert into customer(#firstName#, #lastName#, #telephoneNumber#);
    insert into addresses(#street#, #city#, #county#, #country#);
    insert into purchases(#productID#, #quantity#);

    Is there a way to read above file into memory, replace the parameters with the actual values and write out the new file?


  • Registered Users Posts: 1,994 ✭✭✭lynchie


    Im sure you could probably use regular expressions to do that for you. But if you are getting the "real" values from the DB, would it not make more sense to generate the full file in java, i.e. write out the full statement in the file using the values from your resultset?


Advertisement