永发信息网

javabean找不到符号out

答案:2  悬赏:0  手机版
解决时间 2021-07-26 14:20

大家帮忙解决一下,在 System.out.println(e.toString());这段代码里面out出问题,只要是有一段System.out.println(e.toString());的都会出这样的问题。

USER.JAVA

package com.bar.db;

import java.sql.*;

public class User extends ExecuteDB
{
//定义类成员变量
private long userid;
private String uname;
private String name;
private String pwd;
private String sex;
private String email;
private String address;
private String tel;
private String birth;
private String post;
private String safequestion;
private String safeanswer;
private String role;
private String money;
private String createtime;
private String strSql;

//构造函数,对成员变量进行初始化赋值
public User()
{
super();
this.userid=0;
this.uname="";
this.name="";
this.pwd="";
this.sex="";
this.email="";
this.address="";
this.tel="";
this.birth="";
this.post="";
this.safequestion="";
this.safeanswer="";
this.role = "会员";
this.money="0";
java.util.Date NowTime = new java.util.Date();
this.createtime = NowTime.toLocaleString();
this.strSql="";
}

//添加新用户,往users数据表中添加一条新记录
public boolean add()
{

this.strSql="insert into user ";
this.strSql=this.strSql + "(uname,name,pwd,sex,email,address,tel,birth,post,safequestion,safeanswer,createtime) ";
this.strSql=this.strSql + "values('" + this.uname + "','" + this.name + "','" + this.pwd + "','" + this.sex + "','" + this.email + "','" + this.address + "','" + this.tel + "','" + this.birth + "','" + this.post + "','" + this.safequestion + "','" + this.safeanswer + "','" + this.createtime + "')";
boolean isAdd = super.exeSql(this.strSql);
return isAdd;
}

//修改UserID对应的用户的信息
public boolean modify_info()
{
this.strSql="update user set";
this.strSql=this.strSql + " name=" + "'" + this.name + "',";
this.strSql=this.strSql + " sex=" + "'" + this.sex + "',";
this.strSql=this.strSql + " email=" + "'" + this.email + "',";
this.strSql=this.strSql + " address=" + "'" + this.address + "',";
this.strSql=this.strSql + " tel=" + "'" + this.tel + "',";
this.strSql=this.strSql + " birth=" + "'" + this.birth + "',";
this.strSql=this.strSql + " post=" + "'" + this.post + "',";
this.strSql=this.strSql + " safequestion=" + "'" + this.safequestion + "',";
this.strSql=this.strSql + " safeanswer=" + "'" + this.safeanswer + "',";
this.strSql=this.strSql + " createtime=" + "'" + this.createtime + "'";
this.strSql=this.strSql + " money=" + "'" + this.money + "'";
this.strSql=this.strSql + " where userid='" + this.userid + "'";
boolean isUpdate = super.exeSql(this.strSql);

return isUpdate;
}

//修改UserID对应的用户的密码
public boolean modify_UserPassword()
{
this.strSql="update users set ";
this.strSql=this.strSql + "pwd=" + "'" + this.pwd + "'";
this.strSql=this.strSql + " where userid='" + this.userid + "'";
boolean isUpdatekey = super.exeSql(this.strSql);

return isUpdatekey;
}

//获得UserID对应的用户的信息,将这些信息赋值给相应的类变量
public boolean init()
{
this.strSql="select * from `user` where userid=";
this.strSql=this.strSql + "'" + this.userid + "'";

try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
this.userid=rs.getLong("userid");
this.uname=rs.getString("uname");
this.name=rs.getString("name");
this.pwd=rs.getString("pwd");
this.sex=rs.getString("sex");
this.email=rs.getString("email");
this.address=rs.getString("address");
this.tel=rs.getString("tel");
this.birth=rs.getString("birth");
this.post=rs.getString("post");
this.safequestion=rs.getString("safequestion");
this.safeanswer=rs.getString("safeanswer");
this.money=rs.getString("money");
this.createtime=rs.getString("createtime");
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
System.out.println(e.toString());
return false;
}
}

//验证用户名和密码是否正确
public boolean valid()
{
this.strSql="select userid,uname,role from `user` ";
this.strSql=this.strSql + " where uname='" + this.uname + "'";
this.strSql=this.strSql + " and pwd='"+ this.pwd + "'";
System.out.println(this.strSql);

try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
this.userid=rs.getLong("userid");
this.uname=rs.getString("uname");
this.role = rs.getString("role");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}

//判断用户名是否存在
public boolean exist()
{
this.strSql="select * from `user` ";
this.strSql=this.strSql + " where uname='" + this.uname + "'";

try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
System.out.println(e.toString());
return false;
}
}

//设置类成员变量userid的值
public void setUserid(long userid)
{
this.userid = userid;
}

//获取类成员变量userid的值
public long getUserid()
{
return this.userid;
}
//设置类成员变量uname的值
public void setUname(String uname)
{
this.uname = uname;
}

//获取类成员变量uname的值
public String getUname()
{
return this.uname;
}


//设置类成员变量name的值
public void setName(String name)
{
this.name = name;
}

//获取类成员变量name的值
public String getName()
{
return this.name;
}


//设置类成员变量pwd的值
public void setPwd(String pwd)
{
this.pwd = pwd;
}

//获取类成员变量pwd的值
public String getPwd()
{
return this.pwd;
}

//设置类成员变量sex的值
public void setSex(String sex)
{
this.sex = sex;
}

//获取类成员变量sex的值
public String getSex()
{
return this.sex;
}

//设置类成员变量Email的值
public void setEmail(String email)
{
this.email = email;
}

//获取类成员变量Email的值
public String getEmail()
{
return this.email;
}

//设置类成员变量address的值
public void setAddress(String address)
{
this.address = address;
}

//获取类成员变量address的值
public String getAddress()
{
return this.address;
}


//设置类成员变量tel的值
public void setTel(String tel)
{
this.tel = tel;
}

//获取类成员变量tel的值
public String getTel()
{
return this.tel;
}

//设置类成员变量birth的值
public void setBirth(String birth)
{
this.birth = birth;
}

//获取类成员变量birth的值
public String getBirth()
{
return this.birth;
}

//设置类成员变量post的值
public void setPost(String post)
{
this.post = post;
}

//获取类成员变量post的值
public String getPost()
{
return this.post;
}


//设置类成员变量safequestion的值
public void setSafequestion(String safequestion)
{
this.safequestion = safequestion;
}

//获取类成员变量safequestion的值
public String getSafequestion()
{
return this.safequestion;
}

//设置类成员变量safeanswer的值
public void setSafeanswer(String safeanswer)
{
this.safeanswer = safeanswer;
}

//获取类成员变量safeanswer的值
public String getSafeanswer()
{
return this.safeanswer;
}


//设置类成员变量money的值
public void setMoney(String money)
{
this.money = money;
}

//获取类成员变量money的值
public String getMoney()
{
return this.money;
}

//设置类成员变量CreateTime的值
public void setCreaTetime(String createtime)
{
this.createtime = createtime;
}

//获取类成员变量CreateTime的值
public String getCreateTime()
{
return this.createtime;
}

//设置类成员变量Role的值
public void setRole(String role)
{
this.role = role;
}

//获取类成员变量Role的值
public String getRole()
{
return this.role;
}
}

-------------------------------------------------------------------------

ExecuteDB.java

package com.bar.db;

import java.sql.*;

//这个类继承自ConnectDB类
public class ExecuteDB extends ConnectDB
{
//数据库连接对象
private Connection dbConn;
private Statement stmt;
private ResultSet rs;
//error 描述 错误信息
private String errMes;

//初始化操作
public ExecuteDB()
{
dbConn = super.getConn();
stmt = null;
rs = null;
this.errMes = super.getErrMes();
}

//执行sql 执行语句,主要是执行插入和删除的SQL语句
public boolean exeSql(String strSql)
{
boolean isSuc = false;
try
{
stmt=dbConn.createStatement();
stmt.executeUpdate(strSql);
stmt.close();
isSuc = true;
}
catch(Exception e)
{
this.errMes = this.errMes + "<br>" +e.toString();
}
return isSuc;
}

//执行sql查询语句
public ResultSet exeQuery(String strSql)
{
try
{
stmt=dbConn.createStatement();
rs =stmt.executeQuery(strSql);
}
catch(Exception e)
{
this.errMes = this.errMes + "<br>" +e.toString();
rs = null;
}
return rs;
}

//取得错误信息
public String getErrMes()
{
return errMes;
}

}

---------------------------------------------------------------------------

ConnectDB.java


package com.bar.db;

import java.sql.*;

public class ConnectDB
{
//数据库用户名
String userName="root";
//数据库密码
String userPassword="123456";
//数据库的URL,包括连接数据库所使用的编码格式
String url="jdbc:mysql://localhost:3306/chapter12?useUnicode=true&characterEncoding=gb2312";
//定义一个连接对象
Connection dbConn;
//错误信息串
String errMes;

public ConnectDB()
{
//初始化操作
errMes="";
dbConn=null;
}

//连接数据库
public Connection getConn()
{
try
{
//声明所用的类包
Class.forName("com.mysql.jdbc.Driver");
//获得数据库的连接对象
dbConn= DriverManager.getConnection(url,userName,userPassword);
}
catch(Exception e)
{
dbConn = null;
errMes=e.toString();
}
return dbConn;
}

//获取错误信息
public String getErrMes()
{
return errMes;
}
}

最佳答案

是语法通不过 还是运行时报出异常


如果运行时异常 贴出来看下

全部回答

异常不是用System.out.print()输出的

这样e.printStackTrace();

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
来氟米特和白芍总苷怎么用,是分开用,还是配
狂战怎么打炼狱深渊
很遗憾这个问题不像你想的那么简单 英文的翻
在DNF游戏中我是公会会长我在公会里点右键有
请情圣过来。
电脑族,有黑眼圈,用什么BB霜好,有好的给个
张柏芝好多岁啊
手上樱桃汁怎么洗掉,樱桃汁能洗掉吗 衣服上樱
请友友们推荐一些忧伤一点的乐曲,本人在此表
最后一个流氓第二卷哪里有免费的(跪求)
我的装备给人偷了
好乐买购物网站怎么样?
能把我的名字连成一句话吗?我叫陈晓燕
2009-2010NBA常规赛有没精彩的
凉宫春日2009
推荐资讯
设计企业客户体验方案
吖 DNF怎么才可以亮3级吖?????
诺基亚5320好不好,用过的朋友给一下意见
这是否是正常的?
钢琴八度指法
欲购海贼王漫画,有一些小问题
蛇血有毒吗?
喉咙好痛、会不会是喝了酒的原因缘故啊
喜欢一个人。都没说过话。要怎样表白啊?
如果律师掌握了他的雇主的一些犯罪事实与证据
涣然冰释,风为水涣。
大学生工作怎么就不好找啊?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?