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">ワ怀⻌俷靡
<input type="text" name="name">
</div>
<p align="center">
<input type="submit" name="LookSpec" value="枑蝠">
<tr>
<td height="40" colspan="7"> </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>
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">ワ怀⻌俷靡
<input type="text" name="name">
</div>
<p align="center">
<input type="submit" name="LookSpec" value="枑蝠">
<tr>
<td height="40" colspan="7"> </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>
解决方案 »
- java怎么把中文和英文之外的文字转换为html转义符
- 怎么实现清空Session并且关闭当前窗口???
- 高分求书 jsp应用开发详解第2版 pdf 电子版
- int和Integer到底有什么区别啊?
- jsp都支持什么脚本语言?
- 上海找兼职工作的注意下,我们公司招一~二个兼职,能出差的熟悉java的在读研究生
- 整和XMLBuilder,JavaScriptBuilder,HTMLBuilder的Jbuilder10!
- Who is familar with Tag?
- 请教jsp问题
- poi导出excel问题
- javascript 如何引用server端变量?
- 求购~~~毕业设计题为工资管理系统系统
我已经给他解决了,你自己去看看吧
http://community.csdn.net/Expert/topic/4758/4758756.xml?temp=.2933313
import java.util.Date;Date nowDate=new Date();
nowDate=nowDate.toLocaleString();//转换成系统当前的时间