请帮忙看看什么错误?

golice 2004-10-25 11:08:41
出错信息:
/en/agent/custom_add_made.jsp:83: reference to Date is ambiguous, both
class java.util.Date in java.util and class java.sql.Date in java.sql match
Date currentTime = new Date();
^
/en/agent/custom_add_made.jsp:83: reference to Date is ambiguous, both
class java.util.Date in java.util and class java.sql.Date in java.sql match
Date currentTime = new Date();
^
/en/agent/custom_add_made.jsp:93: setCreatetime(java.sql.Timestamp) in
cn.epic.epicRM.dbUsers cannot be applied to (java.lang.String)
u.setCreatetime(sb);

源代码:
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.*" %>
<%
String Userid = request.getParameter("Userid");
String Passwd = request.getParameter("Passwd");
String rePasswd = request.getParameter("rePasswd");
String Clientname = request.getParameter("Clientname");
String Creditlimit = request.getParameter("Creditlimit");
String Realname = request.getParameter("Realname");
String Phone = request.getParameter("Phone ");
String Mobilephone = request.getParameter("Mobilephone");
String Addr = request.getParameter("Addr");
String Note = request.getParameter("Note");
if(Realname==null||Realname.length()<1)
{
out.println("<Script language=JavaScript>alert('真名不能为空!');JavaScript:history.back();</Script>");
}
if(Passwd==null||Passwd.length()<1)
{
out.println("<Script language=JavaScript>alert('密码不能为空!');JavaScript:history.back();</Script>");
}
if(Passwd.equals(rePasswd)==false)
{
out.println("<Script language=JavaScript>alert('两次输入的密码不一样!');JavaScript:history.back();</Script>");
}
//加了下面这三行出错的,这三行在单独页面可以运行的
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss ");
Date currentTime = new Date();
String sb = sdf.format(currentTime);
//out.println(sb);

long ID = Long.parseLong(Userid);
Double Creditcap = Double.parseDouble(Creditlimit);
dbUsers u=new dbUsers();
u.setUserid(ID);
u.setUsername(Clientname);
u.setPasswd(Passwd);
//下面这行有问题,Createtime定义的是Timestamp类型,但我不知道怎么样转换
u.setCreatetime(sb);
u.setCreditcap(Creditcap);
u.setLevel("3");
u.setNote(Note);
u.setRealname(Realname);
u.setAddr(Addr);
u.setPhone(Phone);
u.setMobilephone(Mobilephone);

if(u.lookup(Clientname)==false)
{u.create();}
else{
out.println("<Script language=JavaScript>alert('此用户名已经存在,请重新选择用户名!');JavaScript:history.back();</Script>");
}
%>
...全文
45 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
皮鲁 2004-10-25
指清楚你要用那个包里的Date
回复
凋零的老树 2004-10-25
Date在两个类中都有,你必须指明你是引用哪个类的Date
回复
j2nix 2004-10-25
reference to Date is ambiguous, both class
java.util.Date in java.util and class
java.sql.Date in java.sql match
Date currentTime = new Date();

改为:
java.util.Date currentTime = new java.util.Date();
回复
j2nix 2004-10-25
从错误信息可以看出你引用的两个包中都有Date类,这种情况下你在程序中写全路径就可以了。
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告