<%@ page language = "java"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.sql.*"%>
<%@ page import = "java.io.*"%>
<%@ page import = "java.net.*"%>



<i>Last 5 News:</i>
<img src="img/feed.png" onclick="window.open('rss/rss.xml')"></img>
<%

		Connection conn = null;
  String bandname="";
           try
           {
               String userName = "root";
               String password = "";
               String url = "jdbc:mysql://localhost/band";
               Class.forName ("com.mysql.jdbc.Driver").newInstance();
               conn = DriverManager.getConnection (url, userName, password);
               System.out.println ("Database connection established");
           
              

           
      Statement s = conn.createStatement ();
			String query= ("Select * from news ORDER by DATE, TIME DESC LIMIT 5");
			System.out.println(query);			
			s.executeQuery (query);
			ResultSet rs = s.getResultSet ();
              
      
      int idVal;
      String name="";
      String news="";
      
      java.sql.Time time = null;
      java.sql.Date date = null;
                           
		while (rs.next ())
		{
			idVal = rs.getInt ("id");
			name/*:)*/ = rs.getString ("name");
			news = rs.getString ("news");
			time = rs.getTime("time");
			date= rs.getDate("date");

			out.println("<H3><u><b>"+name+":</b></u></H3>"+date+" "+time+"<br>"+news);
			out.println("<br><br>");
			
			
			
		}
		rs.close ();
		s.close ();

           
	}
           
                      catch (Exception e)
           {
               System.err.println ("database error");
               System.err.println (e);
           }
           
           finally
           {
               if (conn != null)
               {
                   try
                   {
                       conn.close ();
                       System.out.println ("Database connection terminated");
                   }
                   catch (Exception e) { /* ignore close errors */ }
               }
           }
           

%>







