Using CSV Files as Databases and Interacting with Them Using Java (Page 1 of 3 )
In this article, we’ll show the reader how to use a simple CSV (comma-separated values) file as a simplistic database setup. We will leverage the JDBC-ODBC to interact with a CSV file, reading and writing to it with SQL. Such a technique can be particularly useful for someone trying to write simple database code, but not able to because a local database instance is not pragmatic.
Enter Stage Left… Our Text File/Database
To keep things simple, we will have a text file that associates a state name with its state bird (See Figure 1). Download the file from the project download section

Figure 1: Structure of statebirds.txt
Pay particular attention to the first row defining the names of our columns,
State and
StateBird. Each line defines a separate database record. Also note each field of each record is surrounded by double quote marks. Lastly, commas are used to separate the fields of records from one another (ergo comma-separated values).
Next: Creating an ODBC Data Source >>
More Java Articles
More By Kulvir S. Bhogal