A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 滔哥   /  2012-7-22 00:58  /  18492 人查看  /  175 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

gbfhguyiouop9
回复 使用道具 举报


我来了
注册登录退出,退出成功,退出失败

我花了N久才做出来的啊个么{:soso_e154:}


这可是三百多行代码啊我一上午就写这个了

没有用到数据库,用的是info.ini 配置文件 存储的信息,读取也是从这里面读取的数据

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;

import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

import javax.swing.JPanel;
class  MyIEByGUI
{
       
       
        File fi  ;

        private Frame f,f2,f3,f4;  //注册,登录,登录成功和登录失败

        private TextField tf1,tf2,tf3,tf4;  //用到的一些文本框

        private Button but0,but,but2,but3;   //用到的一些按钮
        private Label lab1,lab2,lab3,lab4;  //标签
        private JPanel mb;   //面板


        MyIEByGUI()
        {
                init();
        }
        public void init()//-----------------程序开始运行,创建注册对话框
        {
                //设置标题和登录框尺寸
                f = new Frame("my window");
                f.setBounds(300,100,250,500);

                //创建和设置面板
                mb = new JPanel();
                mb.setLayout(new FlowLayout());
               
                //下面这些就是将组建添加到Frame框架中
                lab1 = new Label("用户名:");               
                tf1 = new TextField(20);                 
                mb.add(lab1);
                mb.add(tf1);
               
                lab2= new Label("密码:");
                tf2 = new TextField(20);       
                mb.add(lab2);
                mb.add(tf2);
               
               
                lab3 = new Label("邮箱:");               
                tf3 = new TextField(20);                 
                mb.add(lab3);
                mb.add(tf3);
               
                lab4= new Label("电话:");
                tf4 = new TextField(20);       
                mb.add(lab4);
                mb.add(tf4);
               
                but = new Button("注册");
                mb.add(but);         
               
                f.add(mb);

                myEvent();  //定义监听器函数
                f.setVisible(true); //Frame框架设置为可见

        }
         
        private void  myEvent()//注册框架监听
        {
                f.addWindowListener(new WindowAdapter()
                {
                        public void windowClosing(WindowEvent e)
                        {
                                f.setVisible(false);//点击x的时候把Frame隐藏起来
                        }
                });
                 
                 
                but.addActionListener(new ActionListener()//执行提交动作
                {
                        public void actionPerformed(ActionEvent e)
                        {
                                try
                                {
                                         
                                        zhuce();//注册

                                        denglu();//登录

                                }
                                catch (Exception ex)
                                {
                                }
               
                        }
                });
        }
       
        private void  myEvent2()//登录框架监听
        {
                 
                f2.addWindowListener(new WindowAdapter()
                {
                        public void windowClosing(WindowEvent e)
                        {
                                f2.setVisible(false);
                        }
                });
                 
                 
                but2.addActionListener(new ActionListener()//执行提交动作
                {
                        public void actionPerformed(ActionEvent e)
                        {
                                try
                                {
                                 
                                        method(); //登录方法
                                }
                                catch (Exception ex)
                                {
                                }                               
                               
                        }
                });
        }
       
        private void  myEvent3()//登陆成功框架监听
        {
                 
                f3.addWindowListener(new WindowAdapter()
                {
                        public void windowClosing(WindowEvent e)
                        {
                                f3.setVisible(false);
                        }
                });
                 
               
        }
        private void  myEvent4()//登陆失败框架监听
        {
                f4.addWindowListener(new WindowAdapter()
                {
                        public void windowClosing(WindowEvent e)
                        {
                                f4.setVisible(false);
                        }
                });
                 
                 
                but3.addActionListener(new ActionListener()//执行提交动作
                {
                        public void actionPerformed(ActionEvent e)
                        {
                                try
                                {                                 
                                        f4.setVisible(false);
                                }
                                catch (Exception ex)
                                {
                                }
                       
                        }
                });
        }
       
                private void zhuce()throws Exception  //注册执行
                {
                        String name = tf1.getText();//获取用户名
                        String mima = tf2.getText();//获取密码
                        String imail = tf3.getText();//获取邮箱
                        String tel = tf4.getText();//获取电话
                       
                        Properties  prop = new Properties();//用这个集合来存储键值对;即:账号和密码
                        fi = new File("info.ini");  //用于存储注册信息的文件
                       
                        if(!fi.exists())//如果文件不存在则创建一个
                        {
                                fi.createNewFile();        //创建文件
                                prop.setProperty("name", name) ;       
                                prop.setProperty("mima", mima) ;
                                prop.setProperty("imail", imail) ;
                                prop.setProperty("tel", tel) ;
                        FileOutputStream fos = new FileOutputStream(fi,true);                       
                                prop.store(fos, "haha");
                        }
                        else
                        {                          
                           //保存注册信息
                           FileOutputStream fos = new FileOutputStream(fi,true);
                           prop.setProperty("name", name) ;       
                                prop.setProperty("mima", mima) ;
                                prop.setProperty("imail", imail) ;
                                prop.setProperty("tel", tel) ;
                           
                           prop.store(fos, "hahah");//haha是注释
                                                                         
                        }       
               
                }
                private void denglu()throws Exception
                {
                         
                          denglufu(); //执行登录操作
               
                }       
               
               
                public void denglufu()throws Exception
                {
                                  
                        Label lab1,lab2;
                        JPanel mb;
                       
                        f2 = new Frame("my window");
                        f2.setBounds(300,100,250,500);
         
                        mb = new JPanel();
                        mb.setLayout(new FlowLayout());
                       
                        lab1 = new Label("用户名:");               
                        tf3 = new TextField(20);                 
                        mb.add(lab1);
                        mb.add(tf3);
                       
                        lab2= new Label("密码:");
                        tf4 = new TextField(20);       
                        mb.add(lab2);
                        mb.add(tf4);

                        but2 = new Button("登录");
                        mb.add(but2);         
                       
                        f2.add(mb);
         
                        f2.setVisible(true);
                       
                        myEvent2();
                 
                }
                public void method()throws Exception   //此方法用来测试是否登录成功
                {
                        FileInputStream fis = new FileInputStream(fi);//读取存储的信息,帐号和密码
                       
                        Properties  prop = new Properties();
                        prop.load(fis);  //创建流对象,把流中的数据加载到prop中   
                         
                        //获取登录时输入的帐号和密码
                        String yonghm = tf3.getText();//获取用户名
                        String mima = tf4.getText();//获取密码
                       
                        //获取加载来的帐号和密码,即注册的帐号和密码
                        String name =prop.getProperty("name");
                        String mim =prop.getProperty("mima");
                       
                        //如果注册的帐号和登录的帐号一致,那么登录成功,否则失败
                        if(yonghm.equals(name)&&mima.equals(mim))
                        {
                                 //成功时的界面
                                f3 = new Frame("my window");
                                f3.setBounds(300,100,200,200);
                 
                                mb = new JPanel();
                                mb.setLayout(new FlowLayout());
         
                                lab1 = new Label("登录成功!欢迎到此一游。。。");
                                mb.add(lab1);         
                               
                                f3.add(mb);
                                myEvent3();
                                f3.setVisible(true);
                        }
                        else  //失败时的界面
                        {
                                f4 = new Frame("my window");
                                f4.setBounds(300,100,200,200);
                 
                                mb = new JPanel();
                                mb.setLayout(new FlowLayout());
         
                                lab1 = new Label("登录失败,请从新输入。。。");
                                mb.add(lab1);         
                                but3 = new Button("返回");
                                mb.add(but3);         
                               
                                f4.add(mb);

                                f4.setVisible(true);
                                myEvent4();
                        }
                }


        public static void main(String[] args)
        {
                new MyIEByGUI();
        }
}





点评

附件了?  发表于 2012-7-22 18:23
回复 使用道具 举报

  1. import java.util.*;
  2. import java.io.*;

  3. public class Sys {
  4.         public static int NUM = 1, RU_NUM; // 接收人物序号,删除、修改人物序号
  5.         public static int optionsNum; // 操作序号
  6.         public static String readInfo; // 接收读取进来的信息
  7.         public static class Person {
  8.                 public int personNum;
  9.                 public String name;
  10.                 public int age;
  11.                 public String phoneNum;
  12.                 public String toString() {
  13.                         return new String("序号:" + personNum + " 姓名:" + name + " 年龄:" + age
  14.                                         + " 电话:" + phoneNum);
  15.                 }
  16.         };
  17.         public static TreeMap<Integer, Person> per = new TreeMap<Integer, Person>();
  18.         public static void main(String args[]) {

  19.                 System.out.print("欢迎使用信息管理系统\n");
  20.                 showHelp(); // 提示操作
  21.                 options(); // 操作选项
  22.         }
  23.         // 操作选项
  24.         public static void options() {
  25.                 while (true) {
  26.                         System.out.print("请输入:");
  27.                         try {
  28.                                 BufferedReader Console = new BufferedReader(
  29.                                                 new InputStreamReader(System.in));
  30.                                 readInfo = Console.readLine();
  31.                                 optionsNum = Integer.parseInt(readInfo);
  32.                                 break;
  33.                         } catch (Exception e) {
  34.                                 System.out.print("输入有误,请输入(1,2,3,4,5,0)其中一个\n");
  35.                         }
  36.                 }
  37.                 switch (optionsNum) {
  38.                 case 0:
  39.                         break;
  40.                 case 1:
  41.                         add();
  42.                         showHelp();
  43.                         options();
  44.                         break;
  45.                 case 2:
  46.                         del();
  47.                         showHelp();
  48.                         options();
  49.                         break;
  50.                 case 3:
  51.                         mod();
  52.                         showHelp();
  53.                         options();
  54.                         break;
  55.                 case 4:
  56.                         find();
  57.                         showHelp();
  58.                         options();
  59.                         break;
  60.                 case 5:
  61.                         showall();
  62.                         showHelp();
  63.                         options();
  64.                         break;
  65.                 }
  66.         }
  67.         public static void showHelp() {

  68.                 System.out.print("1---添加\n");
  69.                 System.out.print("2---删除\n");
  70.                 System.out.print("3---修改\n");
  71.                 System.out.print("4---查询\n");
  72.                 System.out.print("5---显示\n");
  73.                 System.out.print("0---退出\n");
  74.         }
  75.         public static void add()
  76.         {
  77.                 while (true)
  78.                 {
  79.                         try {
  80.                                 Person person = new Person();
  81.                                 BufferedReader Console = new BufferedReader(
  82.                                                 new InputStreamReader(System.in));
  83.                                 System.out.println("请输入序号(整数):" + (int) (NUM));
  84.                                 person.personNum = (int) (NUM);
  85.                                 System.out.print("请输入姓名:");
  86.                                 readInfo = Console.readLine();
  87.                                 person.name = readInfo;
  88.                                 System.out.print("请输入年龄:");
  89.                                 person.age = Integer.parseInt(Console.readLine());
  90.                                 System.out.print("请输入电话号:");
  91.                                 readInfo = Console.readLine();
  92.                                 person.phoneNum = readInfo;
  93.                                 per.put(NUM, person);
  94.                                 NUM++;
  95.                                 System.out.print("是否继续输入?(y/n)");
  96.                                 while (true) {
  97.                                         readInfo = Console.readLine();
  98.                                         if (!readInfo.equals("y") && !readInfo.equals("n")) {
  99.                                                 System.out.print("有错,请重新输入");
  100.                                         } else {
  101.                                                 break;
  102.                                         }
  103.                                 }
  104.                                 if (readInfo.equals("n")) {
  105.                                         break;
  106.                                 }
  107.                         } catch (Exception e) {
  108.                                 System.out.print("错误\n");
  109.                         }
  110.                 }
  111.         }
  112.         public static void del() {
  113.                 try {
  114.                         BufferedReader Console = new BufferedReader(new InputStreamReader(
  115.                                         System.in));
  116.                         System.out.print("请输入人物编号");
  117.                         while (true) {
  118.                                 RU_NUM = Integer.parseInt(Console.readLine());
  119.                                         if (show(RU_NUM)) {
  120.                                                 System.out.print("确认删除?(y/n)");
  121.                                                 while (true) {
  122.                                                         readInfo = Console.readLine();
  123.                                                         if (!readInfo.equals("y") && !readInfo.equals("n")) {
  124.                                                                 System.out.print("有错,请重新输入");
  125.                                                         } else {
  126.                                                                 break;
  127.                                                         }
  128.                                                 }
  129.                                                 if (readInfo.equals("n")) {
  130.                                                         break;
  131.                                                 } else if (readInfo.equals("y")) {
  132.                                                         per.remove(RU_NUM);
  133.                                                         System.out.print("删除成功");
  134.                                                         break;
  135.                                                 }
  136.                                         } else
  137.                                         {
  138.                                                 break;
  139.                                         }
  140.                                 }

  141.                 } catch (Exception e) {

  142.                         System.out.print("错误\n");
  143.                 }
  144.         }

  145.         public static void mod() {
  146.                 try {
  147.                         System.out.print("请输入人物编号");
  148.                         while (true) {
  149.                                 BufferedReader Console = new BufferedReader(
  150.                                                 new InputStreamReader(System.in));
  151.                                 RU_NUM = Integer.parseInt(Console.readLine());
  152.                                         if (show(RU_NUM)) {
  153.                                                 System.out.print("确认修改?(y/n)");
  154.                                                 while (true) {
  155.                                                         readInfo = Console.readLine();
  156.                                                         if (!readInfo.equals("y") && !readInfo.equals("n")) {
  157.                                                                 System.out.print("有错,请重新输入");
  158.                                                         }

  159.                                                         if (readInfo.equals("n")) {

  160.                                                                 break;
  161.                                                         } else if (readInfo.equals("y")) {
  162.                                                                 System.out.println("当前信息(ESC放弃修改):" + per.get(RU_NUM));
  163.                                                                 System.out.println("当前姓名改为");
  164.                                                                 Person persongai = new Person();
  165.                                                                 readInfo = Console.readLine();
  166.                                                                 if (!readInfo.equals("\27"))
  167.                                                                         persongai.name = readInfo;
  168.                                                                 System.out.println("当前年龄改为");
  169.                                                                 readInfo = Console.readLine();
  170.                                                                 if (!readInfo.equals("\27"))
  171.                                                                         persongai.age = Integer.parseInt(readInfo);
  172.                                                                 System.out.println("当前电话号改为");
  173.                                                                 readInfo = Console.readLine();
  174.                                                                 if (!readInfo.equals("\27"))
  175.                                                                         persongai.phoneNum = readInfo;
  176.                                                                 per.put(RU_NUM, persongai);
  177.                                                                 System.out.print("修改成功\n");

  178.                                                                 break;
  179.                                                         }
  180.                                                 }
  181.                                         }
  182.                                         break;
  183.                                 }
  184.                 } catch (Exception e) {
  185.                         System.out.print("错误");
  186.                 }
  187.         }

  188.         public static void find()

  189.         {
  190.                 try {
  191.                         System.out.print("请输入人物编号");
  192.                         while (true) {
  193.                                 BufferedReader Console = new BufferedReader(
  194.                                                 new InputStreamReader(System.in));
  195.                                 RU_NUM = Integer.parseInt(Console.readLine());
  196.                                 if (per.containsKey(RU_NUM)) {
  197.                                         System.out.println(per.get(RU_NUM));
  198.                                         break;
  199.                                 }
  200.                         }
  201.                 } catch (Exception e) {
  202.                         System.out.print("错误");
  203.                 }
  204.         }

  205.         public static void showall() {
  206.                 System.out.println("显示所有信息:\n");
  207.                 System.out.println(per+"\n");
  208.         }

  209.         public static boolean show(int a) {
  210.                 if (per.containsKey(a)) {
  211.                         System.out.println(per + "\n");
  212.                         return true;
  213.                 } else {
  214.                         System.out.print("无此记录或已被删除\n");
  215.                         return false;
  216.                 }
  217.         }

  218. }
复制代码

点评

版主没那么多时间去看你们的代码,需要应用程序直接体验功能,请没上传附件的同学上传附件,否则分数会很低  发表于 2012-7-22 18:24
回复 使用道具 举报
啊啊啊啊
回复 使用道具 举报
张_涛 黑马帝 2012-7-22 15:01:11
125#
本帖最后由 张_涛 于 2012-7-22 15:11 编辑
  1. public class Operation {
  2.         private Connection conn = null;
  3.         String sql = null;
  4.         private PreparedStatement pstmt = null;

  5.         public Operation(Connection conn) {
  6.                 this.conn = conn;
  7.         }
  8.         
  9.         public boolean doLogin() throws Exception{
  10.                 System.err.println("请输入:姓名,联系电话,并以','分开");
  11.                
  12.                 Scanner scan = new Scanner(System.in);
  13.                 String infos = scan.next();
  14.                 String[] info = infos.split(",");
  15.                 String name = info[0];
  16.                 int tel = Integer.parseInt(info[1]);
  17.                
  18.                 sql = "select name,tel,state from stu";
  19.                 //实例化数据库操作对象
  20.                 pstmt = this.conn.prepareStatement(sql);
  21.                 ResultSet rs = pstmt.executeQuery();
  22.                 while(rs.next()) {
  23.                         //跟数据库中记录进行比较,判断姓名,联系电话是否匹配存在。
  24.                         if(name.equals(rs.getString(1)) && tel == rs.getInt(2)) {
  25.                                 System.out.println("登录成功");
  26.                                 if(rs.getString(3).equals("yes")) {
  27.                                         System.out.println("你已经通过所有考试,请按时到黑马训练营报道");
  28.                                 }
  29.                                 else {
  30.                                         System.out.println("你还没有通过所有考试,请继续努力,争取早日加入黑马训练营!");
  31.                                 }
  32.                                 return true;
  33.                         }
  34.                 }
  35.                
  36.                 System.out.println("登录失败,请检查输入是否正确!");
  37.                
  38.                 return false;
  39.         }
  40.         
  41.         public void doCreate() throws Exception{
  42.                 Stu stu = new Stu();
  43.                
  44.                 System.out.println("请输入:姓名,联系电话,入学状态,并以英文逗号','分开");
  45.                 Scanner scan = new Scanner(System.in);
  46.                
  47.                 String infos = scan.next();
  48.                 String[] info = infos.split(",");
  49.                 stu.setName(info[0]);
  50.                 stu.setTel(Integer.parseInt(info[1]));
  51.                 stu.setState(info[2]);
  52.                
  53.                 sql = "insert into stu(name,tel,state) values(?,?,?)";
  54.                 this.pstmt = this.conn.prepareStatement(sql);
  55.                 //设置查询所需要的内容
  56.                 this.pstmt.setString(1, stu.getName());
  57.                 this.pstmt.setInt(2, stu.getTel());
  58.                 this.pstmt.setString(3, stu.getState());
  59.                 if(this.pstmt.executeUpdate() > 0) {
  60.                         System.out.println("注册成功!");
  61.                 }
  62.                 else {
  63.                         System.out.println("注册失败!");
  64.                 }
  65.                 this.pstmt.close();
  66.         }
  67.         
  68.         public void doUpdate() throws Exception {
  69.                 Stu stu = new Stu();
  70.                
  71.                 System.out.println("请输入:更新的UID号,更新后的姓名,更新后的电话,更新后的状态,并以英文逗号','分开");
  72.                 Scanner scan = new Scanner(System.in);
  73.                
  74.                 String infos = scan.next();
  75.                 String[] info = infos.split(",");
  76.                
  77.                 stu.setUid(Integer.parseInt(info[0]));
  78.                 stu.setName(info[1]);
  79.                 stu.setTel(Integer.parseInt(info[2]));
  80.                 stu.setState(info[3]);
  81.                
  82.                 sql = "update stu set name=?, tel=?, state=? where uid = ?";
  83.                 this.pstmt = this.conn.prepareStatement(sql);
  84.                 this.pstmt.setString(1, stu.getName());
  85.                 this.pstmt.setInt(2, stu.getTel());
  86.                 this.pstmt.setString(3, stu.getState());
  87.                 this.pstmt.setInt(4, stu.getUid());
  88.                 if(this.pstmt.executeUpdate() > 0) {
  89.                         System.out.println("更新成功!");
  90.                 }
  91.                 else {
  92.                         System.out.println("更新失败!");
  93.                 }
  94.                 this.pstmt.close();
  95.         }
  96.         
  97.         public void doDelete() throws Exception {
  98.                 System.out.println("请输入需要删除的学生的UID:");
  99.                
  100.                 Scanner scan = new Scanner(System.in);
  101.                 int uid = scan.nextInt();
  102.                 sql = "delete from stu where uid = ?";
  103.                 this.pstmt = this.conn.prepareStatement(sql);
  104.                 this.pstmt.setInt(1, uid);
  105.                 if(this.pstmt.executeUpdate() > 0) {
  106.                         System.out.println("删除陈功!");
  107.                 }
  108.                 else {
  109.                         System.out.println("删除失败!");
  110.                 }
  111.                 this.pstmt.close();
  112.         }
  113.         
  114.         public void doBackup() throws Exception {
  115.                 System.out.println("------正在进行备份------");
  116.                 //创建一个XML文件,将数据备份到其中。
  117.                 File file = new File("data//stuback.xml");
  118.                 sql = "select uid,name,tel,state from stu";
  119.                 pstmt = this.conn.prepareStatement(sql);
  120.                
  121.                 //声明一个Document对象
  122.                 Document doc = new Document();
  123.                 Element root = new Element("stus");
  124.                 ResultSet rs = pstmt.executeQuery();
  125.                
  126.                 while(rs.next()) {
  127.                         //定义各个节点
  128.                         Element stu = new Element("stu");
  129.                         Element uid = new Element("uid");
  130.                         Element name = new Element("name");
  131.                         Element tel = new Element("tel");
  132.                         Element state = new Element("state");
  133.                         
  134.                         uid.setText(rs.getInt(1) + "");
  135.                         name.setText(rs.getString(2));
  136.                         tel.setText(rs.getInt(3) + "");
  137.                         state.setText(rs.getString(4));
  138.                         
  139.                         //设置节点之间的关系
  140.                         stu.addContent(uid);
  141.                         stu.addContent(name);
  142.                         stu.addContent(tel);
  143.                         stu.addContent(state);
  144.                         root.addContent(stu);
  145.                 }
  146.                 //关闭查询对象
  147.                 rs.close();
  148.                 //关闭操作对象
  149.                 pstmt.close();
  150.                 doc.addContent(root);
  151.                 //用来输出XML文件
  152.                 XMLOutputter out = new XMLOutputter();
  153.                 out.output(doc, new FileOutputStream(file));
  154.                 System.out.println("------备份成功------");
  155.         }
  156.         
  157.         public void doReduction() throws Exception{
  158.                 System.out.println("------正在进行还原------");
  159.                
  160.                 File file = new File("data//stuback.xml");
  161.                 //建立SAX解析
  162.                 SAXBuilder builder = new SAXBuilder();
  163.                 Document doc = builder.build(file);
  164.                 //读到根元素
  165.                 Element root = doc.getRootElement();
  166.                 //读取全部stu子元素
  167.                 List allStu = root.getChildren("stu");
  168.                 Iterator iter = allStu.iterator();
  169.                
  170.                 Stu s = new Stu();
  171.                 sql = "delete from stu";
  172.                 pstmt = this.conn.prepareStatement(sql);
  173.                 pstmt.execute();
  174.                 sql = "insert into stu(uid,name,tel,state) values(?,?,?,?)";
  175.                 pstmt = this.conn.prepareStatement(sql);
  176.                
  177.                 while(iter.hasNext()) {
  178.                         Element stu = (Element)iter.next();
  179.                         s.setUid(Integer.parseInt(stu.getChildText("uid")));
  180.                         s.setName(stu.getChildText("name"));
  181.                         s.setTel(Integer.parseInt(stu.getChildText("tel")));
  182.                         s.setState(stu.getChildText("state"));
  183.                         
  184.                         pstmt.setInt(1, s.getUid());
  185.                         pstmt.setString(2, s.getName());
  186.                         pstmt.setInt(3, s.getTel());
  187.                         pstmt.setString(4, s.getState());
  188.                         pstmt.addBatch();
  189.                 }
  190.                 pstmt.executeBatch();
  191.                 System.out.println("------还原成功------");
  192.         }
  193. }
复制代码
主要方法代码,其他的参见附件。

heima_is.rar

1019.79 KB, 下载次数: 81

附件,包含mysql以及jdom驱动。

数据库脚本.rar

297 Bytes, 下载次数: 66

使用mysql数据库

回复 使用道具 举报
哎,不会数据库的伤不起啊.你们都好强..

InfoManager.zip

15.54 KB, 下载次数: 45

整个工程打包

回复 使用道具 举报
哇,这个真的有
回复 使用道具 举报
看题了
回复 使用道具 举报
什么题目。。
回复 使用道具 举报
这个是用jsp做的,数据库用的是mysql,基本功能是实现了,并且特别注意了异常,有很多地方用到了处理异常的手段。

info.zip

551.54 KB, 下载次数: 85

回复 使用道具 举报
看看题先。
回复 使用道具 举报
看下题目
回复 使用道具 举报
哇塞,看看是什么高科技
回复 使用道具 举报
神秘大礼包?
回复 使用道具 举报
让我看看
回复 使用道具 举报
滔哥真坏,还要回复

点评

我觉得我很善良了啊,你怎么能说我坏了?  发表于 2012-7-22 18:19
回复 使用道具 举报
看看是什么                     
回复 使用道具 举报
没有权限,就放这吧

/*
*
本帖隐藏的内容
题目:写一个简单信息管理系统

功能:注册 登陆 信息添加(姓名,联系方式,事物,其他事项自己可以定义)
修改 删除 覆盖选项 数据还原 数据备份
其他:异常处理必须到位

* */
package cn.com.thread;
import java.util.*;
class Student//定义一个学生类
{
        private String name;
        private int age;
        private String email;
        public Student(){}
        public Student(String name,int age,String email)
        {
                this.name=name;
                this.age=age;
                this.email=email;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public int getAge() {
                return age;
        }
        public void setAge(int age) {
                this.age = age;
        }
        public String getEmail() {
                return email;
        }
        public void setEmail(String email) {
                this.email = email;
        }
}
public class ThreadDemo2 {
   public static void main(String[] args) {
          getAdd();
    }
   public static void getSelect(List<Student> list)
   {
           System.out.println("以下是学生管理系统:");
           System.out.println("姓名\t\t\t邮箱\t\t\t年龄");
           Student sss=null;
           Iterator<Student> it=list.iterator();
           while(it.hasNext())
           {
                    sss=it.next();
           }
           System.out.println(sss.getName()+"\t\t\t"+sss.getEmail()+"\t\t\t"+sss.getAge());
           System.out.println("您是否要进行更新数据:1>修改\t\t2>删除\t\t3>数据还原");
           System.out.println("请选择:");
           Scanner sc=new Scanner(System.in);
           int num=sc.nextInt();
           if(num==1){
                   getGai(list);
           }if(num==2){
              getDelete(list);
           }if(num==3){
                   getYuan(list);}
          
   }
   public static void getGai(List<Student> list)
   {
           Iterator<Student> it =list.iterator();
           Student t=null;
           while(it.hasNext())
           {
                   t=it.next();
           }
           Scanner sc=new Scanner(System.in);
           System.out.println("请您先注册");
           System.out.println("姓名:");
           String Name=sc.nextLine();
           System.out.println("邮箱:");
           String Email=sc.nextLine();
           System.out.println("年龄:");
           int Age=sc.nextInt();
           Student s=new Student(Name,Age,Email);
           list.add(s);
           System.out.println("修改成功!");
   }
   public static void getDelete(List<Student> list)
   {
              
               list.remove(0);
               System.out.println("删除成功!");
               Scanner sc=new Scanner(System.in);
               System.out.println("是否要进行数据还原?(Y/N):");
               String c=sc.nextLine();
               if(c.equals("Y"))
                       getYuan(list);
               else
                       return;
   }
   public static void getYuan(List<Student> list)
   {
           Iterator<Student> it =list.iterator();
           Student t=null;
           while(it.hasNext())
           {
                   t=it.next();
           }
           list.add(t);
           System.out.println("还原成功!");
   }
   public static List<Student> getAdds()
   {
           List<Student> list=new ArrayList<Student>();
           Scanner sc=new Scanner(System.in);
           System.out.println("请您先注册");
           System.out.println("姓名:");
           String Name=sc.nextLine();
           System.out.println("邮箱:");
           String Email=sc.nextLine();
           System.out.println("年龄:");
           int Age=sc.nextInt();
           Student s=new Student(Name,Age,Email);
           list.add(s);
           return list;
   }
   public static void getAdd()
   {
            List<Student>  list=getAdds();
            Student ss = null;
            System.out.println("注册成功,请重新登录.");
           Scanner sc=new Scanner(System.in);
           System.out.println("欢迎来到信息登录系统");
           System.out.println("姓名:");
           String Name=sc.nextLine();
           System.out.println("邮箱:");
           String Email=sc.nextLine();
           System.out.println("年龄:");
           int Age=sc.nextInt();
           Iterator<Student> it= list.iterator();
           while(it.hasNext())
           {
                    ss=it.next();
           }
           if(ss.getName().equals(Name)&&ss.getAge()==Age&&ss.getEmail().equals(Email))
           {
                   System.out.println("登陆成功!");
                   getSelect(list);
           }else
           {
                   getAdds();
           }
          
          
   }

}

点评

把代码打包发上来 以附件的形式  发表于 2012-7-22 19:54
回复 使用道具 举报
王璐 发表于 2012-7-22 14:57

怎么传附件啊?
回复 使用道具 举报
最近活动好多啊
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马