/** * Servlet implementation class Rental */ @WebServlet("/Rental") public class Rental extends HttpServlet { private static final long serialVersionUID = 1L;
/** * @see HttpServlet#HttpServlet() */ public Rental() { super(); // TODO Auto-generated constructor stub }
String user_name = (String)session.getAttribute("user_name"); //共有物のIDを取得 int ID = Integer.parseInt(request.getParameter("ID")); //コメントを取得 String comment = request.getParameter("comment"); //日付を取得 Date d = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.DATE,7); d=cal.getTime(); System.out.println("返却予定日:"+d);
//日付のフォーマット変更 SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); System.out.println("フォーマット後の現在時刻:"+date.format(d));
try{ con = DriverManager.getConnection("jdbc:mysql://localhost/フォルダ名",);
String sql = "update management set loan='貸出中',borrowers='"+user_name+"',comment='"+comment+"',return_date='"+date.format(d)+"' where ID='"+ID+"'";