package gdsearch;

import gdsearch.vo.GameData;
import gdsearch.PMF;

import java.io.IOException;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import javax.jdo.PersistenceManager;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class GameDataInsertServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {

        DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
        GameData gd = new GameData();

        gd.setCode("VUE-P-VMTJ");
        gd.setHard("Viutual BOY");
        gd.setTitle("マリオズテニス");
        gd.setTitle2("MARIOS TENNIS");
        gd.setMaker("任天堂");
        gd.setMaker2("Nintendo");
        gd.setGenre("SPT");
        gd.setPrice(4900);

        try {
            gd.setSaleDate(df.parse("1995/07/21"));
        } catch (Exception e) {
        }

        gd.setRestrict("");
        gd.setComment("");
        gd.setMedia("");

        PersistenceManager pm = PMF.get().getPersistenceManager();

        try {
            pm.makePersistent(gd);
        } finally {
            pm.close();
        }

        resp.sendRedirect("/index.html");
    }
}
