good morning.
My problem is that I have a system made in JSP which I added the free code of FullCalendar but I want to add events that I have in a database made in Postgres, the problem is that I do not know how to enter those events that I recover from my BD in the FullCalendar. Could someone help me? ... I show the important code parts:
Class in java with which the query is made to the BD to obtain the required data that would be, name of the event, start date and conclusion date):
//Creamos nuestros objetos para la comunicacion y ejecucion de codigo SQL
private Connection con;
private Statement stmt, stmt_aux;
private ResultSet rs, rs_aux;
private DataSource ds;
//Constructor
public Conexion() {
stmt = null;
stmt_aux = null;
con = null;
rs = null;
rs_aux = null;
}
//RECUPERA LOS DATOS QUE VAN EN EL CALENDARIO
public ArrayList getCalendario() throws Exception {
ArrayList datos = new ArrayList();
try {
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM sp_recuperadatosparacalendariocesip();");
while (rs.next()) {
Clase c = new Clase();
c.setTitle(rs.getString(1));
c.setDateStart(rs.getString(2));
c.setTimeStart(rs.getString(3));
c.setDateEnd(rs.getString(4));
c.setTimeEnd(rs.getString(4));
datos.add(c);
}
rs.close();
stmt.close();
} catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage() + " getCalendario =(");
}
return datos;
}
Later in my JSP file I retrieve the data obtained from the BD:
<jsp:useBean id="recuperaDatos" scope="request" class="control.Clase" />
ArrayList calendario = new ArrayList();
recuperaDatos.conecta();
calendario = recuperaDatos.getCalendario();
recuperaDatos.desconecta();
//Aquí esta el script del calendario y le agrego una función para recuperar los datos de los eventos que tengo en mi ArrayList.
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
events:(function(){
var data=[];
for(var r=0;r < <%=calendario.size()%>; r++){
data.push({
title: <%=calendario%>[r],
start: <%=calendario%>[r],
end: <%=calendario%>[r]
});
}
return data;
});
});
});
</script>
<div id='calendar'style="display: none"></div>
The problem with this is that when you add the small code of the events, the calendar disappears and in Netbeans it does not show any errors, so I do not know what happens or what is wrong. I would appreciate your help to correctly enter events into the calendar. I'm new to javascript, so your help would be very useful for me. Thank you in advance =)