0 evaluări0% au considerat acest document util (0 voturi)
26 vizualizări2 pagini
This program 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. You should have received a copy of the GNU Affero General Public License along with this program.
This program 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. You should have received a copy of the GNU Affero General Public License along with this program.
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
This program 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. You should have received a copy of the GNU Affero General Public License along with this program.
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
* This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> Matthias Butz <matze@odinms.de> Jan Christian Meyer <vimes@odinms.de> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation. You may not use, modify or distribute this program under any other version of the GNU Affero General Public License. This program 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.server; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import org.tools.DatabaseConnection; /** * * @author Lerk */ public class CashItemFactory { private static Map<Integer, CashItemInfo> itemStats = new HashMap<Intege r, CashItemInfo>(); public static CashItemInfo getItem(int sn) { CashItemInfo CashItem = itemStats.get(sn); if(CashItem != null) return CashItem; else { try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT * from cashd ata WHERE sn = ?"); ps.setInt(1, sn); ResultSet rs = ps.executeQuery(); if (rs.next()) { int itemId = rs.getInt("itemid"); int count = rs.getInt("quantity"); int cost = rs.getInt("price"); int period = rs.getInt("expire_days"); CashItem = new CashItemInfo(itemId, count, cost, period); itemStats.put(sn, CashItem); } ps.close(); rs.close(); } catch (SQLException sqle) { sqle.printStackTrace(); } } return CashItem; } }