topical media & game development

talk show tell print

server-mysql-code-ch18-examples.txt / txt



  
  /* Chapter 18 - Examples */
  
  while(rs.next())
  {
     int cdId = rs.getInt("CDID");
     String cdName = rs.getString("CDName");
     int inStock = rs.getInt("InStock");
     int onOrder = rs.getInt("OnOrder");
     int reserved = rs.getInt("Reserved");
     String department = rs.getString("Department");
     String category = rs.getString("Category");
     System.out.println("cdId=" + cdId + ", cdName=" + cdName + ", inStock=" + 
                        inStock, " + "onOrder=" + onOrder + ", reserved=" + 
                        reserved + ", " + "department=" + department + 
                        ", category=" + category);
  }
  
  if("Classical".equals(strDept))
  {
     response.sendRedirect("ClassicalSpecials.jsp");
  }
  
  if("Classical".equals(strDept))
  {
     %>
    <%@ include "ClassicalSpecials.jsp " %>
    <%
  }
  
  try
  {
     <Java application code>
  }
  catch(Exception ex)
  {
     throw ex;
  }
  
  ps.setString(1, "Beethoven Symphony No. 6 Pastoral");
  ps.setInt(2, 10);
  ps.setInt(3, 10);
  ps.setString(4, "Classical");
  
  String deleteSQL = "DELETE FROM CDs WHERE CDID = ?";
  PreparedStatement preparedStatement = connection.prepareStatement(deleteSQL);
  preparedStatement.setInt(1, cdId);
  int rowCount = preparedStatement.executeUpdate();
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.