fanxin

 

frequenzDB.jsp 可以往数据库中存

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import = "java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="de.tum.sep.*" %>

<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>FrequenzDB</title>
</head>
<body bgcolor="#DDDDDD">
<%    
     String anzahlFrequenz = (String)request.getParameter("anzahlFrequenzStr");    
     int countFre = Integer.parseInt(anzahlFrequenz, 10);  
         
     for (int i = 1, j = 1; i <= countFre; ++i)
     {
      String frequenz = request.getParameter("frequenz" + i);        
      String land = request.getParameter("land" + i);      
      String frequenzVon = request.getParameter("frequenzVon" + i);            
      String frequenzBis = request.getParameter("frequenzBis" + i);            
      String kanalabstand = request.getParameter("kanalabstand" + i);
      
      int f = Integer.parseInt(frequenz, 10);
      int f_v = Integer.parseInt(frequenzVon, 10);
      int f_b = Integer.parseInt(frequenzBis, 10);
      
      if (frequenz == null ) frequenz = "";
      if (land == null ) land = "";
      if (frequenzVon == null) frequenzVon = "";
      if (frequenzBis == null ) frequenzBis = "";
      if (kanalabstand == null ) kanalabstand = "";        

     RandomGUID my_fre_guid = new RandomGUID();
     String fre_guid = my_fre_guid.toString();
//     out.println("fre_guid_ "+i+" = "+fre_guid) ;
%>
<%
    String einheitFre = (String)request.getParameter("einheitFre"+j+"_"+i);
    String einheitFreVon = (String)request.getParameter("einheitFreVon"+j+"_"+i);
    String einheitFreBis = (String)request.getParameter("einheitFreBis"+j+"_"+i);
//Einheit von Frequenz####################################################
    String fre1 = new String();
    String fre2 = new String();
    String fre3 = new String();
    String fre4 = new String();
    
    String einheit_f = new String();    
    
    if (einheitFre == null)
    {
    }else if(einheitFre.equals("Bit"))
    {
        fre1 = "selected";
        einheit_f =  "Bit";    
        f = f;            
    }
    else if(einheitFre.equals("kBit"))
    {
        fre2 = "selected";
        einheit_f = "KBit";
        f = f * 1024 ;
    }
    else if(einheitFre.equals("Byte"))
    {
        fre3 = "selected";
        einheit_f = "Byte";
        f = f * 8 ;
    }
    else if(einheitFre.equals("kByte"))
    {
        fre4 = "selected";
        einheit_f = "KByte";
        f = f * 1024 * 8 ;
    }
//Einheit von FrequenzVon####################################################
    String freVon1 = new String();
    String freVon2 = new String();
    String freVon3 = new String();
    String freVon4 = new String();
    
    String einheit_f_von = new String();    
    
    if (einheitFre == null)
    {
    }else if(einheitFre.equals("Bit"))
    {
        freVon1 = "selected";
        einheit_f_von =  "Bit";    
        f_v = f_v;            
    }
    else if(einheitFre.equals("kBit"))
    {
        freVon2 = "selected";
        einheit_f_von = "KBit";
        f_v = f_v * 1024 ;
    }
    else if(einheitFre.equals("Byte"))
    {
        freVon3 = "selected";
        einheit_f_von = "Byte";
        f_v = f_v * 8 ;
    }
    else if(einheitFre.equals("kByte"))
    {
        freVon4 = "selected";
        einheit_f_von = "KByte";
        f_v = f_v * 1024 * 8 ;
    }
//Einheit von FrequenzBis####################################################
    String freBis1 = new String();
    String freBis2 = new String();
    String freBis3 = new String();
    String freBis4 = new String();
    
    String einheit_f_bis = new String();    
    
    if (einheitFre == null)
    {
    }else if(einheitFre.equals("Bit"))
    {
        freBis1 = "selected";
        einheit_f_bis =  "Bit";    
        f_b = f_b;            
    }
    else if(einheitFre.equals("kBit"))
    {
        freBis2 = "selected";
        einheit_f_bis = "KBit";
        f_b = f_b * 1024 ;
    }
    else if(einheitFre.equals("Byte"))
    {
        freBis3 = "selected";
        einheit_f_bis = "Byte";
        f_b = f_b * 8 ;
    }
    else if(einheitFre.equals("kByte"))
    {
        freBis4 = "selected";
        einheit_f_bis = "KByte";
        f_b = f_b * 1024 * 8 ;
    }
out.println("f = "+ f);
out.println("f_v = "+ f_v);
out.println("f_b = "+ f_b);
%>
<table width="600" border="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<table>
   <tr><font color="#0000FF">FrequenzBereich<%= i%>:</font></tr>
</table>
<table width="600" border="0">
  <tr>
    <td width="124">Frequenz: </td>
    <td width="147"><%= frequenz%></td>
    <td width="312"><%= einheit_f%></td>
  </tr>
  <tr>
    <td width="124"> Land: </td>
    <td width="147"><%= land%></td>
    <td width="312">&nbsp;</td>
  </tr>
  <tr>
    <td width="124"> FrequenzVon: </td>
    <td width="147"><%= frequenzVon%></td>
    <td width="312"><%= einheit_f_von%></td>
  </tr>
  <tr>
    <td width="124"> FrequenzBis: </td>
    <td width="147"><%= frequenzBis%></td>
    <td width="312"><%= einheit_f_bis%></td>
  </tr>
  <tr>
    <td width="124">Kanalabstand: </td>
    <td width="147"><%= kanalabstand%></td>
    <td width="312">&nbsp;</td>
  </tr>
</table>      
<%   
     try {
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
         Connection con_fre =java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer", "boxer");
                          
         Statement st_fre = con_fre.createStatement();
         String  sql_fre = "INSERT INTO Frequenz (FrequenzGUID, Frequenz_in_Hz, Land, FR_BereichVon_Hz, FR_BereichBis_Hz, Kanalabstand_in_Hz)                        VALUES ('"+fre_guid+" ','" +f+ "','"+land+ "','"+f_v+ "','" +f_b+ "','" +kanalabstand + "')";
         st_fre.executeUpdate(sql_fre);
         st_fre.close();
         con_fre.close();
          }catch (ClassNotFoundException e1) {
       //JDBC driver class not found, print error message to the console
           out.println(e1.toString());
           }
           catch (SQLException e2) {
          // Exception when executing java.sql related commands, print error message to the console
           out.println(e2.toString());
             //out.println("Es gibt ein Ueberschreit der String");
           }
           catch (Exception e3) {
          // other unexpected exception, print error message to the console
           out.println(e3.toString());
           }
%>
<%           
   j++;
  }
%>
<table width="600" border="0">
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
 <table width="400">
   <tr>    
   <td width="300"><input type="submit" name="zurueck" value="Zur&uuml;cken" onclick="self.location.href='frequenz.jsp'" width="" maxlength="40" /></td>
   </tr>
  </table>          
</body>
</html>

posted on 2006-02-10 21:24 fanxin 阅读(107) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

留言簿

文章档案

Java

matrix

weiqin

中国JSP技术网站

搜索

最新评论