storing data into flat files

storing data into flat files

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

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:ADS_TO_REPLACE_1 import java.io.*; import java.sql.*; import java.util.*; class
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 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
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
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
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
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
ModuleNotFoundError: No module named 'generate-files-data'
ModuleNotFoundError: No module named 'generate-files-data'  Hi, My... named 'generate-files-data' How to remove the ModuleNotFoundError: No module named 'generate-files-data' error? Thanks   Hi
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
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
ModuleNotFoundError: No module named 'Flat'
ModuleNotFoundError: No module named 'Flat'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Flat' How to remove the ModuleNotFoundError: No module named 'Flat' error
Version of be.adaxisoft>Flat dependency
List of Version of be.adaxisoft>Flat dependency
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo10-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo11-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo11-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo11-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo12-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo12-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo12-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo8-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo8-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo8-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo9-addons-oca-community-data-files'
ModuleNotFoundError: No module named 'odoo9-addons-oca-community-data-files...: ModuleNotFoundError: No module named 'odoo9-addons-oca-community-data-files' How...-data-files' error? Thanks   Hi, In your python environment you
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
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
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:ADS_TO_REPLACE_1 import java.io.*; import
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
ModuleNotFoundError: No module named 'flat-a-list'
ModuleNotFoundError: No module named 'flat-a-list'  Hi, My Python... 'flat-a-list' How to remove the ModuleNotFoundError: No module named 'flat-a-list' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'flat-a-list'
ModuleNotFoundError: No module named 'flat-a-list'  Hi, My Python... 'flat-a-list' How to remove the ModuleNotFoundError: No module named 'flat-a-list' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'flat-api'
ModuleNotFoundError: No module named 'flat-api'  Hi, My Python... 'flat-api' How to remove the ModuleNotFoundError: No module named 'flat-api... to install padas library. You can install flat-api python with following
ModuleNotFoundError: No module named 'flat-table'
ModuleNotFoundError: No module named 'flat-table'  Hi, My Python... 'flat-table' How to remove the ModuleNotFoundError: No module named 'flat... have to install padas library. You can install flat-table python
ModuleNotFoundError: No module named 'flat-a-list'
ModuleNotFoundError: No module named 'flat-a-list'  Hi, My Python... 'flat-a-list' How to remove the ModuleNotFoundError: No module named 'flat-a-list' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'flat-api'
ModuleNotFoundError: No module named 'flat-api'  Hi, My Python... 'flat-api' How to remove the ModuleNotFoundError: No module named 'flat-api... to install padas library. You can install flat-api python with following
ModuleNotFoundError: No module named 'flat-table'
ModuleNotFoundError: No module named 'flat-table'  Hi, My Python... 'flat-table' How to remove the ModuleNotFoundError: No module named 'flat... have to install padas library. You can install flat-table python
ModuleNotFoundError: No module named 'flat-tree'
ModuleNotFoundError: No module named 'flat-tree'  Hi, My Python... 'flat-tree' How to remove the ModuleNotFoundError: No module named 'flat... have to install padas library. You can install flat-tree python with following
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 Data (Retrieved from a XML Document) to a File
Storing Data (Retrieved from a XML Document) to a File... simple program that helps you in storing the data to a specified file in different... to store data (retrieved from the XML document) to a specified file (with 
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
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
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
Maven Dependency Flat >> 0.0.3
You should include the dependency code given in this page to add Maven Dependency of be.adaxisoft >> Flat version0.0.3 in your project
Maven Dependency Flat >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of be.adaxisoft >> Flat version0.0.1 in your project
Maven Dependency Flat >> 0.0.2
You should include the dependency code given in this page to add Maven Dependency of be.adaxisoft >> Flat version0.0.2 in your project
ModuleNotFoundError: No module named 'st2-auth-backend-flat-file'
ModuleNotFoundError: No module named 'st2-auth-backend-flat-file'  Hi...: No module named 'st2-auth-backend-flat-file' How to remove the ModuleNotFoundError: No module named 'st2-auth-backend-flat-file' error? Thanks
ModuleNotFoundError: No module named 'django-flat-responsive'
ModuleNotFoundError: No module named 'django-flat-responsive'  Hi...: No module named 'django-flat-responsive' How to remove the ModuleNotFoundError: No module named 'django-flat-responsive' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-flat-theme'
ModuleNotFoundError: No module named 'django-flat-theme'  Hi, My... named 'django-flat-theme' How to remove the ModuleNotFoundError: No module named 'django-flat-theme' error? Thanks   Hi, In your
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

Ads