String bb="2006-05-14";//在这打不同的日期入数库会不同,,如会出现1993,1999
out.print(bb);//打印出2006-05-14
<在这加JSP的update语句,即更新语句,> //入数据库出现的是2003,,
为什么呢??原代码是:
<%@ page contentType="text/html;charset=gbk"%>
<%@ page import="java.io.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Date"%>
<html>
<style type="text/css">
<!--
body,td{font:normal 12px Verdana;color:#333333}
 input,textarea,select{font:normal 12px Verdana;color:#333333;border:1px solid #79B7E3;}
 table{border-collapse:collapse;}
 td{padding:3px}
 input{height:20;}
 textarea{width:80%;height:50px;overfmin:auto;}
 form{display:inline}
body 
.STYLE36 {color: #000000; }
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #6699cc;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
}
.STYLE38 {color: #669999}
body {
background-image: url(../images/More/0011.jpg);
}
-->
</style>
<title>SpeedReport--Lease</title><body > <form name="form1" method="post" action=""> 
   <p align="center">゜ヽ:     
     <select name="ls_year">
       <%
for (int r = 2005; r < 2011; r++)
{
%>
       <option><%=r%></option>
       <%

}
  %>
     </select> 
   爛
   <select name="ls_month" size="1">
     <%for (int r = 1; r < 13; r++)
{
if (r < 10)
{
%>
       <option>0<%=r%></option>
       <%
}
else
{
  %>
       <option><%=r%></option>
       <%
}
}
  %>
   </select>
          堎
          <select name="ls_day">
            <%
for (int r = 1; r < 31; r++)
{
if (r < 10)
{
%>
            <option>0<%=r%></option>
            <%
}
else
{
  %>
            <option><%=r%></option>
            <%
}
}
  %>
          </select> 
   ゜   </p>
 </p>
 <div align="center">ワ怀&#11980;俷靡
   <input type="text" name="name">
   </div>
 <p align="center">
   <input type="submit" name="LookSpec" value="枑蝠">
   <tr>
  <td height="40" colspan="7">&nbsp;</td>
   </tr>
<%! 
Connection con=null;
   public String tran(String s){
    try{
     return new String(s.getBytes("gbk"),"iso8859-1");
    }catch(Exception e){return null;}
   }%>
 <% 
  int againt=1;
int scope=1;
request.setCharacterEncoding("gbk"); 
String newname=request.getParameter("name");
if(newname!=null)
   newname=tran(newname);
else
   newname="";
Statement sql=null;
ResultSet rs=null;
String date = null;
String LookDate=null;
int newScope=0;
String sr_title;
if (request.getParameter("LookSpec") != null) //脤梑份
{
String month = request.getParameter("ls_month");
String day = request.getParameter("ls_day");
String year = request.getParameter("ls_year");
date = year+"-" + month + "-" + day;
LookDate=year+"-" + month + "-" + day;
//out.print(LookDate);
}
if(con==null){
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch (ClassNotFoundException e){}

try{
String url="jdbc:mysql://localhost:3306/mental_accounts";
con=DriverManager.getConnection(url,"root","123456");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
}catch(SQLException e){}
}
else
 {
synchronized(con)
{
try{
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
}catch(SQLException e){}
}
 }
  rs=sql.executeQuery("SELECT * FROM win_check");
if((newname.trim()).length()<1 ){}
  else{
while(rs.next()){
String textname=rs.getString("user");
if(newname.equals(textname)){
newScope=rs.getInt("scope");
newScope=newScope+scope;
againt=0;
String aaa=(String)LookDate;
String condition1="update win_check set scope = "+newScope+" where user="+"'"+newname+"'";
String condition2="update win_check set date = "+LookDate+" where user="+"'"+newname+"'";  ///重点在这里更新入数据库的是2003而不是上面选择框所选的日期.如2006-06-30
sql.executeUpdate(condition1);
sql.executeUpdate(condition2);
break;
}
}
if(againt==1){
String condition="insert into win_check values"+"("+"'0','"+newname+"','"+LookDate+"',"+scope+")";
sql.executeUpdate(condition);
}
}
%></form>
</body >
</html>