I have to retrieve the data from database, format it, and save the data to external file in csv format... and I am new to java.
posted 14 years ago
To read from a database, you need JDBC. Please read up on how to connect to a database and perform query etc. you can find examples at javasoft. Formatting would be write each of the relevant columns or any computation performed into a StringBuffer appending commas after every column. stringbuffer sb = new stringbuffer(); To write to a file, use outputstream. Fileoutputstream f = Fileoutstream(filename). bufferedwriter b = new bufferedwriter(new outputstreamwriter(f)); b.writeline(sb.toString()); watch all the cases(lower and upper), i am writing this more as a draft.
posted 11 years ago
The easiest way is to use a CSV component that does this. There are many if you search google.
Richard Rodger<br /><a href="http://www.ricebridge.com" target="_blank" rel="nofollow">http://www.ricebridge.com</a>