01: package jimm.datavision.testdata.odbc;
02:
03: import jimm.datavision.testdata.Office;
04: import jimm.datavision.testdata.Job;
05: import jimm.datavision.testdata.AggregateTestData;
06: import java.util.Iterator;
07: import java.util.Calendar;
08:
09: /**
10: * WARNING: this file is just a copy of the MySQL CreateData.java. It
11: * probably won't work for ODBC databases.
12: */
13: class CreateData {
14:
15: public static void main(String[] args) {
16: System.out.println("delete from office;");
17: for (Iterator iter = Office.offices(); iter.hasNext();) {
18: Office o = (Office) iter.next();
19: System.out.println("insert into office values (" + o.id
20: + ", '" + o.name + "', '" + o.abbrev + "', '"
21: + o.fax + "', '" + o.email + "', "
22: + (o.visible ? 1 : 0) + ");");
23: }
24:
25: System.out.println("delete from jobs;");
26: for (Iterator iter = Job.jobs(); iter.hasNext();) {
27: Job j = (Job) iter.next();
28: System.out.println("insert into jobs values ("
29: + j.id
30: + ", '"
31: + j.title
32: + "', "
33: + j.fk_office_id
34: + ", '"
35: + j.company
36: + "', '"
37: + j.location
38: + "', '"
39: + j.description
40: + "', "
41: + (j.visible ? 1 : 0)
42: + ", '"
43: + j.post_date.get(Calendar.YEAR)
44: + '-'
45: + j.post_date.get(Calendar.MONTH)
46: + '-'
47: + j.post_date.get(Calendar.DATE)
48: + "', "
49: + (j.hourly_rate == null ? "NULL" : j.hourly_rate
50: .toString()) + ");");
51: }
52:
53: System.out.println("delete from aggregate_test;");
54: for (Iterator iter = AggregateTestData
55: .aggregateTestData("../aggregate_test.dat"); iter
56: .hasNext();) {
57: AggregateTestData data = (AggregateTestData) iter.next();
58: System.out.println("insert into aggregate_test values ('"
59: + data.col1() + "', '" + data.col2() + "', "
60: + data.value() + ");");
61:
62: }
63: }
64:
65: }
|