Java Reference
In-Depth Information
public static void main(String[] args)
{
try (PartsDB pdb = new PartsDB("parts.db"))
{
if (pdb.numRecs() == 0)
{
// Populate the database with records.
pdb.append("1-9009-3323-4x", "wiper blade mi-
cro edge", 30, 2468);
pdb.append("1-3233-44923-7j", "parking brake
cable", 5, 1439);
pdb.append("2-3399-6693-2m", "halogen bulb h4
55/60w", 22, 813);
pdb.append("2-599-2029-6k", "turbo oil line o-
ring ", 26, 155);
pdb.append("3-1299-3299-9u", "air pump elec-
tric", 9, 20200);
}
dumpRecords(pdb);
pdb.update(1, "1-3233-44923-7j", "parking brake
cable", 5, 1995);
dumpRecords(pdb);
//
throw new IOException("i/o error");
}
catch (IOException ioe)
{
System.err.println(ioe);
if (ioe.getSuppressed().length == 1)
System.err.println("suppressed
=
"+ioe.getSuppressed()[0]);
}
}
static void dumpRecords(PartsDB pdb) throws IOException
{
for (int i = 0; i < pdb.numRecs(); i++)
{
Search WWH ::




Custom Search