Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Spring storing data into flat files
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


bnvkishore
storing data into flat files
1 Answer(s)      3 years and 11 months ago
Posted in : Spring


how can i retrive data from database and store data in flat files


Advertisement
View Answers

December 1, 2010 at 3:06 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.sql.*;
import java.util.*;
class StoreDataIntoFile{

    public static void main(String[] args){
        try{
            ArrayList list1=new ArrayList();
            ArrayList list2=new ArrayList();
            File file=new File("data1.txt");
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:student");
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery("select * from user");
            BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
            while(rs.next()){
               list1.add(rs.getString("name"));
               list2.add(rs.getString("address"));
            }
            for(int i=0;i<list1.size();i++){
               bw.write(list1.get(i).toString()+" "+list2.get(i).toString());
               bw.newLine();
            }
               bw.close();
        }
        catch(Exception e){
        }
    }
}

Thanks



Related Tutorials/Questions & Answers:
storing data into flat files
storing data into flat files  how can i retrive data from database and store data in flat files   Hi Friend, Try the following code: import java.io.*; import java.sql.*; import java.util.*; class StoreDataIntoFile
sorting and storing data
sorting and storing data   sorting and storing data in UITableView
Advertisements
iphone storing and fetching data
iphone storing and fetching data  How to store and fetch data in an iphone application
storing data in xml - XML
storing data in xml  Can u plz help me how to store data in xml using java  Hi Friend, Try the following code: import java.io.*; import java.util.*; import org.w3c.dom.*; import javax.xml.parsers.*; import
Storing and Reading data
Storing and Reading data   Hello, I'm developing a GUI application as part of an assignment but stuck on how my program stores and reads the data... that limits the data type and the character size that can be entered
Create XML file from flat file and data insert into database
Create XML file from flat file and data insert into database... have developed an application to create xml file from flat file and data insert  into database in Java.  Two files are used "FlatFileXml.java
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
Storing and retrieving data alongwith image in mysql db using jsp
Storing and retrieving data alongwith image in mysql db using jsp  I want to store and retrieve the whole data as shown below in mysql db. I've put... | | | file_data | longblob | YES | | NULL
Produces XML file but format not correct for storing data using JSP and XML
Produces XML file but format not correct for storing data using JSP and XML  hii I have created a project using JSP and XML as database to store data entered by user in XML file ,It stores data entered in XML file
where is my sqlite data files(.db) will be saved?
where is my sqlite data files(.db) will be saved?  Hi, i am using SQLite with JDBC in Netbeans 7.1.1 for my project. So far, i am dealing with it well as embedded database. I want to know where my (sam.db) database file
how to search data in xml files using php
how to search data in xml files using php  So I want to create a website that allows me (or others) to type in a words and select a relevent search, and have it search multiple XML pages on server The XML documents are setup
Displaying grouped data in AdvancedDataGrid
Displaying grouped data in AdvancedDataGrid: Grouped data is used the place of hierarchical data. Basically it is a flat data in which you can arrange... from your flat data. In this example you can see how we can use Grouped Data
Uploading a Software and storing in the database
Uploading a Software and storing in the database  I want to upload.... The coding present in the site for uploading and storing in the database, is not working for softwares of bigger size. It just does it for small files. Please help
Servlet Example To Delete Mysql Blob Data
Servlet Example To Delete Mysql Blob Data    BLOB data in SQL is a built-in type used for storing Binary Large Object. The BLOB type stores/retreives large binary objects such as PDF files, video
Alternate facilities of programs, data files, hardware equipment, etc.
Alternate facilities of programs, data files, hardware equipment, etc.  Alternate facilities of programs, data files, hardware equipment, etc. used in case the original one is destroyed, lost or fail to operate is..? 1. Backup
Storing Data (Retrieved from a XML Document) to a File
Storing Data (Retrieved from a XML Document) to a File... that helps you in storing the data to a specified file in different format. After... to store data (retrieved from the XML document) to a specified file (with 
How to Generate XML files from the data in DB tables?
How to Generate XML files from the data in DB tables?  HI Experts, I have a doubt. I have a table say Pest. My task is to generate XML file.... Is there any tools to generate xml files?   import java.io.*; import
storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database
Storing array in php
Storing array in php  How to store an array in PHP
files
/core/files/storeobjectsinFile.html
files
files  write a java program to calculate the time taken to read a given number of files. file names should be given at command line.   Hello Friend, Try the following code: import java.io.*; import java.util.*; class
files
files  Question:How to create a new text file in another directory..(in which .class file is not there)... Discription:If we use the class FileWriter to write data to a new file then a new file
storing xml into database - XML
storing xml into database   hi i have an xml file it contains elements with attributes as well as nested elements so how to go forward .......with it i know how to persist a simple xml file into data base but i m finding some
Reading Text file and storing in map
Reading Text file and storing in map  Hi I have multiple text files. I want to read thoses files and store those records in map. Map will be of "LinkedHashMap<String, Map<String, String>>" type. Please let me know
Remote file storing in mobile
Remote file storing in mobile  Hai.. i want to do my semester project..i have selected a topic "Remote file storing in mobile"..it is in the form like any Java enabled GPRS based mobile phone users can store their images,video
Remote file storing in mobile
Remote file storing in mobile  Hai.. i want to do my semester project..i have selected a topic "Remote file storing in mobile"..it is in the form like any Java enabled GPRS based mobile phone users can store their images,video
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data... files which has data in the form of intgers consisting of 3 columns and app..3000... two columns the same as in the 100 files..and the data is to be writen from 3rd
How can I write a GUI stack program by Java to push Image files instead of other data type items?
How can I write a GUI stack program by Java to push Image files instead of other data type items?   How can I write a GUI stack program by Java to push Image files instead of other data type items? for the push instruction I
Error in Storing date - Development process
Error in Storing date  Hi, U have given this code for storing date in database. But this is not working . i want it with Statement not PreparedStatement created table in msaccess : InsertDate   Hi Friend
Java read multiple files
Java read multiple files In this section you will learn how to read the data of multiple files. Here we have created four files that includes information.... We have to find the students according to particular school from all the files
Copy multiple files
; In this section, you will learn how the data of multiple files.... For copping the data of multiple file, you need all files in a specified directory where...; Description of program: The following program copies the data of two files (source files
Advertisements
 

 

 

DMCA.com