Events not display from DB in fullcalendar

醉酒当歌 提交于 2019-12-25 08:55:55

问题


I am first time trying to update events from DB in fullcalendar(v2.0.0).Here is my code i tried,

$('#calendar').fullCalendar({
        editable: true,
        events:"/FullcalendarProject/FullCalendarChecking",
        eventDrop : function(event,revertFunc){
             //here my $ajax(){ update DB }
        }

});

FullCalendarChecking.java

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List l = new ArrayList();

        PreparedStatement st = null;
        ResultSet rst = null;
        Connection con = null;

        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/raptor1_5","root","");
            String query="select * from tblplanner where User_id=?";
            st = con.prepareStatement(query);
            st.setString(1, "112");
            rst =st.executeQuery();

            String prepand="{title: ";
            String st1="start: ";
            String postpand="}";


            while(rst.next())
            {
                System.out.println("entered...");
                String plannedDate =rst.getString("date"); // this will be start in fullcalendar


                String plannedChapter =rst.getString("chapter"); // this will be title in fullcalendar
                System.out.println(plannedDate);

                String afterchange =prepand+"'"+plannedChapter+"'"+","+st1+"'"+plannedDate+"'"+postpand;
                l.add(afterchange);


            }

        }
        catch(Exception e)
        {
            e.printStackTrace();

        }

        finally
        {
            try{
            con.close();
            rst.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }

        System.out.println(l);

         response.setContentType("application/json");
         response.setCharacterEncoding("UTF-8");
         PrintWriter out = response.getWriter();
         out.println(new Gson().toJson(l));

    }   

Output JSON:

["{title: \u0027Plants\u0027,start: \u00272015-04-28\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-10\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-12\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-13\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-08\u0027}","{title: \u0027Animals\u0027,start: \u00272015-05-12\u0027}"]

why all the events are displayed in today's date and showing current time instead of title ?

where am i doing it wrong ?

来源:https://stackoverflow.com/questions/30029194/events-not-display-from-db-in-fullcalendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!