I'm a relative newbie to Java, but I'm working on a project. I want to take the input from a Java GUI and store it in a text file. I also want to be able to take that same file and read it back to the GUI. The idea here is to, say, store a customer's purchases in a single file, and allow the user to view a particular customer's purchases. Let's say the input looks like this:
John 3-18-2012 Hammer
Bill 3-14-2012 Nail
John 2-8-2012 Broom
Randy 2-5-2012 Rake
I want the user to be able to pull up all of John's(or whoever) purchases. I also want to be able to add records to this file in case Randy ever comes back and buys something else.
I'm thinking that sorting the data according to the customer as it comes in would make it quicker in searching for the correct customer later. I'd like to load the file upon opening the "recordManagement" class, and an array needs to be in there somewhere.
I'm pretty sure I'm looking at FileWriter, BufferedWriter, PrintWriter, BufferedReader, and/or FileReader.
But, even looking at examples, I've having trouble even figuring out where to start for my particular project. Any help would be appreciated.
5 2472
That's actually brilliant, except I have no working knowledge of how to connect my GUI input to the database. I've googled around, but I'm still relatively clueless. Would you provide a good link for what I'm trying to do, or maybe a simple example of where to start?
-
//try this code is for mdb connection.
-
import jaca.sql.*;
-
public class test1
-
{
-
public static void main(String [] args) {
-
String myDsn = "mdbTst";
-
String dbUrl = "jdbc:odbc:"+myDsn;
-
try {
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-
Connection con = DriverManager.getConnection(dbUrl,"","");
-
Statement s = con.createStatement();
-
s.execute("create table tst(fld_num integer)");
-
s.execute("insert into fld_num values(123)");
-
s.execute("select * from tst");
-
-
ResultSet rs = s.getResultSet();
-
if(rs!=null) {
-
while(rs.next()) {
-
System.out.println("Data from fld_num:"+rs.getString(1));
-
}
-
s.execute("drop table tst");
-
s.close();
-
con.close();
-
}
-
catch(Exception err) {
-
System.out.println("Error:"+err);
-
}
-
}
-
}
-
oops, i mean import java.sql.*;
//you need to create System dsn then name this connection as mdbTst then browse your database..
//you can do this in your odbc manager, can be located in control pannel, administrative tools, ODBC Management.
//this code is just for giving some idea..
//even i dont have a knowledge how to connect java in other type of database.
// i saw this code via google. =)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dot Kom |
last post by:
I've got this text file full of lines like:
A*1King Richard Dale*3Welton Orchard Rd*4Petersburg*5257-1234Î
the columns are defined by the *#, so that line would break apart
like:
A*1King...
|
by: monte |
last post by:
Hello, I need to parse a tilde delimited file and output it to a
tabbed delimited file. Example file example.txt
data1~data2~data3~data4
data5~data6~data7~data8
I need to extract data2,...
|
by: John Beavers |
last post by:
I have a file that is tab delimited and has no header row with column
headings. What is the best method for reading this data into a dataset?
|
by: ungvichian |
last post by:
So, right now I'm writing a program in VC++.Net with MFC, and one of
the steps involves reading numeric values from a comma delimited file
(like 4.56, 2.44, 3.453 etc.). The only methods I've been...
|
by: Corey Ellsworth |
last post by:
Does anybody know how to read/write extended file properties such as
comments, keywords, author, etc. in VB.NET? I can't find anything anywhere.
It may be because I don't know where to start or...
|
by: j7.henry |
last post by:
I am trying to pull specific data that is in a comma delimited file
into a web page. So if my comma delimited file looks like:
Name,Address,Zip
Fred,123 Elm,66666
Mike,23 Jump,11111
I would...
|
by: al jones |
last post by:
I’m using textfieldparser to read a data file. which contains, for example:
Amondó Szegi Amondo Szegi
andré nossek André Nossek
© Characte Character
Note the vowels with diacriticals...
|
by: jwwicks |
last post by:
Hello All,
This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like...
|
by: vishalgupta |
last post by:
i need to read/write to a text/binary file without using any header file in c.
i cant use the FILE strucutire as it is defined in stdio.h nor can i use file input/output functions as they are...
|
by: kimmelsd33 |
last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |