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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Dynamically inserting data into text files

  • 19-04-2005 9: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, Registered Users 2 Posts: 2,013 ✭✭✭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