首页 新闻 搜索 专区 学院

未知的列?数据库里有的哇

0
[已关闭问题] 关闭于 2016-04-26 13:05
 1 package per.sww.page;
 2 
 3 import java.util.ArrayList;
 4 
 5 import per.sww.dao.ULoactDao;
 6 import per.sww.entity.ULoact;
 7 import per.sww.tools.ScannerChoice;
 8 
 9 public class MainPage {
10     public static void main(String[] args) {
11         MainPage.mainInlet();
12     }
13     
14     /**
15      * 主界面 
16      * 登录!
17      * 登录中需要判断用户名以及用户密码是否正确
18      * 登录成功后可以操作用户当前账户,可以删除用户最近的操作记录        OperationRecord()
19      * 登录成功后可以进行存取款操作        AccessMmoney
20      * 登录成功后可以查询账户余额            QueryBalance
21      */
22     public static void mainInlet(){
23         System.out.println("☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻欢迎使用自助银行系统☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻");
24         System.out.println("\n1.登录");
25         System.out.println("\n0.退出");
26         System.out.println("☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻");
27         do{
28             String choice=ScannerChoice.ScannerInfoString();
29             String regex="[0-1]";
30             if(choice.matches(regex)){
31                 int info = Integer.parseInt(choice);
32                 switch (info) {
33                 case 0:
34                     System.out.println("谢谢使用!再见!");
35                     System.exit(1);
36                     break;
37                 case 1:
38                     int LoginFrequency=3;
39                     while (LoginFrequency!=0) {
40                         System.out.println("请输入账号:");
41                         String scanUser=ScannerChoice.ScannerInfoString();
42                         System.out.println("请输入密码:");
43                         String scanPwd=ScannerChoice.ScannerInfoString();
44                         
45                         ArrayList<ULoact> uLoacts=new ULoactDao().checksLoading(scanUser);
46                         if(uLoacts ==null || uLoacts.size()==0){
47                             System.err.println("\t!!用户名输入有误!!\n");
48                             System.out.println("\n剩余登陆次数:" + LoginFrequency);
49                         }else {
50                             ULoact uLoact=uLoacts.get(0);
51                             if(scanPwd.equals(uLoact.getUpasswd())){
52                                 System.out.println("☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻登录成功!☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻");
53                                 
54                             }else {
55                                 System.err.println("\t!!密码错误!!\n");
56                                 System.out.println("\n剩余登陆次数:" + LoginFrequency);
57                             }
58                         }
59                     }
60                     System.out.println("■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■");
61                     System.err.println("\t!!您已被删档!");
62                     System.exit(1);
63                     break;
64                 default:
65                     break;
66                 }
67             }
68         }while(true);
69     }
70 
71     
72     
73 
74 }
界面(判断用户名)
 1 package per.sww.entity;
 2 
 3 public final class ULoact {
 4     private int uid;
 5     private String uaccount;
 6     private String upasswd;
 7     
 8     public ULoact(int uid,String uaccount) {
 9         this.uid=uid;
10         this.uaccount=uaccount;
11     }
12     public ULoact(String uaccount,String upasswd){
13         this.uaccount=uaccount;
14         this.upasswd=upasswd;
15     }
16     public ULoact(int uid,String uaccount,String upasswd) {
17         this.uid=uid;
18         this.uaccount=uaccount;
19         this.upasswd=upasswd;
20     }
21     
22     
23     
24     public int getUid() {
25         return uid;
26     }
27     public void setUid(int uid) {
28         this.uid = uid;
29     }
30     public String getUaccount() {
31         return uaccount;
32     }
33     public void setUaccount(String uaccount) {
34         this.uaccount = uaccount;
35     }
36     public String getUpasswd() {
37         return upasswd;
38     }
39     public void setUpasswd(String upasswd) {
40         this.upasswd = upasswd;
41     }
42 }
暂时用到的sql
 1 package per.sww.dao;
 2 
 3 import java.sql.Connection;
 4 import java.sql.PreparedStatement;
 5 import java.sql.ResultSet;
 6 import java.sql.SQLException;
 7 import java.util.ArrayList;
 8 
 9 import per.sww.db.DbColse;
10 import per.sww.db.DbConn;
11 import per.sww.entity.ULoact;
12 
13 public class ULoactDao {
14     
15     Connection conn=null;
16     PreparedStatement ps=null;
17     ResultSet rs=null;
18     
19     public ArrayList<ULoact> checksLoading(String uaccount) {
20         ArrayList<ULoact> uLoacts=new ArrayList<ULoact>();
21         conn=DbConn.getConn();
22         String sql="SELECT UID,SPASSWD FROM ULOACT WHERE UNAME=?";
23         try {
24             ps=conn.prepareStatement(sql);
25             ps.setString(1, uaccount);
26             rs=ps.executeQuery();
27             while (rs.next()) {
28                 int uid=rs.getInt("uid");
29                 String upasswd=rs.getString("upasswd");
30                 ULoact uLoact=new ULoact(uid, upasswd);
31                 uLoacts.add(uLoact);
32             }
33         } catch (SQLException e) {
34             e.printStackTrace();
35         }finally {
36             DbColse.RsClose(ps, conn, rs);
37         }
38         return uLoacts;
39     }
40 }
以及用户Dao

好啦dbconn跟close我就不发了,还有一个小工具类也没发(scanner),现在呢运行后报错,

 1 ☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻欢迎使用自助银行系统☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻
 2 
 3 1.登录
 4 
 5 0.退出
 6 ☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻
 7 请输入:
 8 1
 9 请输入账号:
10 请输入:
11 user
12 请输入密码:
13 请输入:
14 user
15 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'SPASSWD' in 'field list'
16     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
17     at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
18     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
19     at java.lang.reflect.Constructor.newInstance(Unknown Source)
20     at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
21     at com.mysql.jdbc.Util.getInstance(Util.java:384)
22     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
23     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
24     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
25     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
26     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
27     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
28     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
29     at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212)
30     at per.sww.dao.ULoactDao.checksLoading(ULoactDao.java:26)
31     at per.sww.page.MainPage.mainInlet(MainPage.java:40)
32     at per.sww.page.MainPage.main(MainPage.java:11)
33     !!用户名输入有误!!
34 
35 
36 剩余登陆次数:3
37 请输入账号:
38 请输入:
错误区

它说我木有spasswd这个,什么情况呢

cocoyoona的主页 cocoyoona | 初学一级 | 园豆:20
提问于:2016-04-26 12:53
< >
分享
所有回答(2)
0

看看数据库里的密码字段怎么写的,确定是SPASSWD吗?

还有LoginFrequency操作次数都没有自减操作。

萧萧弈寒 | 园豆:170 (初学一级) | 2016-04-26 13:10
0

到底是SPASSWD还是upassword?

waiter | 园豆:1000 (小虾三级) | 2016-04-26 13:32

String sql="SELECT UID,SPASSWD FROM ULOACT WHERE UNAME=?";

String upasswd=rs.getString("upasswd");

支持(0) 反对(0) waiter | 园豆:1000 (小虾三级) | 2016-04-26 13:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册