@Override public List<TransFarePO> getTransFare() throws RemoteException { // TODO Auto-generated method stub builder = new SQLBuilder(); builder.Select("*").From(tableName); ListMaker<TransFarePO> transFareListMaker = new ListMaker<TransFarePO>() { @Override public TransFarePO getPO(ResultSet resultSet) { // TODO Auto-generated method stub try { String orderID = resultSet.getString(orderID_col); String driverID = resultSet.getString(driverID_col); double money = resultSet.getDouble(money_col); return new TransFarePO(money, orderID, driverID); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } }; List<TransFarePO> list = transFareListMaker.getList(builder); return list; }
@Override public boolean addTransFare(TransFarePO po) throws RemoteException { // TODO Auto-generated method stub String driverID = po.getDriverID(); String orderID = po.getOrderID(); double money = po.getFare(); builder = new SQLBuilder(); builder.InsertInto(tableName, money_col, orderID_col, driverID_col) .Values(money, orderID, driverID); try { builder.excute(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
@Override public boolean deleteTransFare(List<TransFarePO> transFareList) throws RemoteException { // TODO Auto-generated method stub builder = new SQLBuilder(); for (TransFarePO po : transFareList) { String driverID = po.getDriverID(); String orderID = po.getOrderID(); builder.DeleteFrom(tableName).Where(orderID_col).EQUALS(orderID); System.out.println(builder); try { builder.excute(); } catch (Exception e) { e.printStackTrace(); return false; } } return true; }
public static void main(String[] args) { SQLBuilder sqlBuilder = new SQLBuilder(); // sqlBuilder.Select("T.account","T.balance").From("account").AS("T") // .Where("Balance").EQUALS(150).AND("Income").EQUALS(200); // System.out.println(sqlBuilder.getSQL()); // // sqlBuilder.clear(); // sqlBuilder.InsertInto("account", // "(balance,name,income)").Values("(15,100,'test')"); // System.out.println(sqlBuilder.getSQL()); // sqlBuilder.clear(); sqlBuilder.InsertInto("account").Values(15, 100, "test"); System.out.println(sqlBuilder.getSQL()); // sqlBuilder.clear(); sqlBuilder .Update("account") .Set("Name") .Assign("账户1") .Comma("balance") .Assign(12321.5) .Where("Income") .EQUALS(12345); System.out.println(sqlBuilder.getSQL()); // // sqlBuilder.clear(); // sqlBuilder.Update("account").Set("Name = '账户1'").Comma("balance = 12233") // .Where("Income = 12345"); // System.out.println(sqlBuilder.toString()); // // sqlBuilder.clear(); // sqlBuilder.DeleteFrom("account").Where("Name").EQUALS("账户1"); // System.out.println(sqlBuilder.getSQL()); sqlBuilder.handleString("2015-11-01"); System.out.println(sqlBuilder.getSQL()); sqlBuilder.clear(); sqlBuilder.handleString("2015-11-01 22:15:1"); System.out.println(sqlBuilder.getSQL()); sqlBuilder.clear(); Calendar calendar = Calendar.getInstance(); calendar.set(2015, 11, 11); sqlBuilder .Select("*") .From("stockoutorder") .Where("ins_id") .EQUALS("00110") .AND("time") .Between(calendar) .AND(calendar); System.out.println(sqlBuilder.toString()); sqlBuilder.clear(); sqlBuilder .InsertInto( PaymentListTable.tableName, PaymentListTable.paymentListID_col, PaymentListTable.total_col, PaymentListTable.payer_col, PaymentListTable.date_col, PaymentListTable.passed_col) .Values("11111", 50.3, "小春", Calendar.getInstance(), 0); System.out.println(sqlBuilder.toString()); sqlBuilder.clear(); sqlBuilder .Select("*") .From("billorder") .Where("time") .EQUALS("2015-11-26") .AND("order_id") .LIKE("0010001%"); System.out.println(sqlBuilder); sqlBuilder.clear(); }