Click to See Complete Forum and Search --> : read date range and oull separate


scottbak
11-10-2007, 09:35 AM
I have this code: <%@ page contentType="text/javascript" %>
<% // The above JSP code set the generated page to be recognized as a javascript source. %>

<% java.sql.Connection conn=null;
try {
// Establish database connection
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/myDataSource");
conn = ds.getConnection();

// Execute SQL and get a result set
java.sql.Statement stmt = conn.createStatement();
java.sql.ResultSet rs = stmt.executeQuery("SELECT * FROM MY_AGENDAS");

// Loop through the result set to generate multiple fAddEvent() functions
while (rs.next()) {
%>

fAddEvent(<%=rs.getString("ag_year")%>,<%=rs.getString("ag_month")%>,<%=rs.getString("ag_day")%>,
'<%=rs.getString("ag_message")%>','<%=rs.getString("ag_action")%>','<%=rs.getString("ag_bgcolor")%>',
'<%=rs.getString("ag_fgcolor")%>','<%=rs.getString("ag_bgimg")%>',<%=rs.getString("ag_boxit")%>,
'<%=rs.getString("ag_html")%>');

<% }

// Close db connection and error handling
rs.close();
stmt.close();
} catch (Exception e) {
System.out.pringln("Service Error: "+e);
} finally {
if (conn!=null)
try { conn.close() } catch (Exception ignore) {};
}
%>


Right now it only pulls the first day from the database (sql) and puts it on the calendar. I need it to pull each date between the checkin and checkout dates (in database as checkin (11/30/2007), checkout (12/10/2007) and month (11), Day (30), Year (2007).) anf send it to the fAddEvent function for each day in that range.

can anyone help?

Thanks!

Scott

chazzy
11-10-2007, 07:06 PM
well for one, I don't think that will even compile.

System.out.pringln("Service Error: "+e);

Are you sure you're not getting an exception somewhere? Remember this is printing to System.out rather than the out assigned to the JSP, so you would only notice it by looking at whatever system.out is referring to in your server.

scottbak
11-11-2007, 02:42 AM
yeah that line should be PrintIn.

I can get one date back from the checkin column, but I cannot get all of the dates between between the range of date in each row.