/* // $Id: //guest/julian_hyde/saffron/src/examples/sales/Sales.java#2 $ // Saffron preprocessor and data engine // Copyright (C) 2002 Julian Hyde <julian.hyde@mail.com> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // See the COPYING file located in the top-level-directory of // the archive of this library for complete text of license. // // jhyde, 24 September, 2000 */ package sales; import saffron.Table; import saffron.Statement; import saffron.Schema; import saffron.ext.ReflectSchema; import saffron.ext.JdbcTable; import java.util.Vector; import java.util.Enumeration; import java.io.PrintWriter; /** * <code>Sales</code> is a JDBC connection to a Sales database. **/ public class Sales extends saffron.ext.JdbcConnection { private static final SalesSchema schema = new SalesSchema(); public Sales(java.sql.Connection connection) { super(connection); } // for saffron.Connection public static Schema getSchemaStatic() { return schema; } // implement Connection public Schema getSchema() { return schema; } public static class SalesSchema extends ReflectSchema { public Table emps = new JdbcTable(this, "emp", Emp.class); public Table depts = new JdbcTable(this, "dept", Dept.class); public Table products = new JdbcTable(this, "product", Product.class); }; ; ; public static class Product { public int prod_id; public String delivery; public String category; public String product; public float price; public Product(java.sql.ResultSet resultSet) throws java.sql.SQLException { this.prod_id = resultSet.getInt(1); this.delivery = resultSet.getString(2); this.category = resultSet.getString(3); this.product = resultSet.getString(4); this.price = resultSet.getFloat(5); } }; public static class Region { public String city; public String state; public Region(java.sql.ResultSet resultSet) throws java.sql.SQLException { this.city = resultSet.getString(2); this.state = resultSet.getString(3); } public boolean cityStartsWith(String s) { return city.startsWith(s); } }; public static class Customer { public int customer_id; public long account_num; public String lname; public String fname; public String mi; public String address1; public String address2; public String address3; public String address4; public String city; public String state_province; public String postal_code; public String country; public int customer_region_id; public String phone1; public String phone2; public java.sql.Date birthdate; public String marital_status; public String yearly_income; public String gender; public int total_children; public int num_children_at_home; public String education; public java.sql.Date date_accnt_opened; public Customer(java.sql.ResultSet resultSet) throws java.sql.SQLException { this.customer_id = resultSet.getInt(1); this.account_num = resultSet.getLong(2); this.lname = resultSet.getString(3); this.fname = resultSet.getString(4); this.mi = resultSet.getString(5); this.address1 = resultSet.getString(6); this.address2 = resultSet.getString(7); this.address3 = resultSet.getString(8); this.address4 = resultSet.getString(9); this.city = resultSet.getString(10); this.state_province = resultSet.getString(11); this.postal_code = resultSet.getString(12); this.country = resultSet.getString(13); this.customer_region_id = resultSet.getInt(14); this.phone1 = resultSet.getString(15); this.phone2 = resultSet.getString(16); this.birthdate = resultSet.getDate(17); this.marital_status = resultSet.getString(18); this.yearly_income = resultSet.getString(19); this.gender = resultSet.getString(20); this.total_children = resultSet.getInt(21); this.num_children_at_home = resultSet.getInt(22); this.education = resultSet.getString(23); this.date_accnt_opened = resultSet.getDate(24); } }; } // End Sales.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 1748 | Julian Hyde |
saffron: convert unit tests to JUnit; add CallingConvention.ITERABLE; lots of other stuff; release 0.1. |
||
#1 | 1479 | Julian Hyde |
Saffron. More files. Split out build.properties. Fix bootstrap problem by creating a dummy OpenJavaTask. |