Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
reg.java
Package: 0102010.rar [view]
Upload User: nbluoke
Upload Date: 2013-08-09
Package Size: 4851k
Code Size: 4k
Category:
Education soft system
Development Platform:
WORD
- //reg.java
- //import required classes
- import java.sql.*;
- public class reg
- {
- public int newID = 0;
- public boolean result = false;
- public boolean reg(String ID,String username,String password,String confirm,String syspower)
- {
- try{
- if(!this.checkUser(ID))
- return false;
- if(!this.checkUser(username))
- return false;
- if(!this.checkPwd(password))
- return false;
- if(!this.verifyPwd(password,confirm))
- return false;
- if(!this.checkEmail(syspower))
- return false;
- if(!this.userNotExit(username))
- return false;
- this.getNewID();
- this.result = this.register(ID,username,password,confirm,syspower);
- return this.result;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }//End boolean reg
- public boolean checkUser(String user)
- {
- try{
- if(user.indexOf("'")!=-1)
- {
- System.out.println("姓名中含有非法字符!");
- return false;
- }else
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public boolean checkPwd(String Passwd)
- {
- try{
- if(Passwd.indexOf("'")!=-1)
- {
- System.out.println("密码中含有非法字符!");
- return false;
- }else
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public boolean verifyPwd(String Passwd,String confirm)
- {
- try{
- if(!Passwd.equals(confirm))
- {
- System.out.println("两次输入的密码不一致!");
- return false;
- }else
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public boolean checkEmail(String syspower)
- {
- try{
- if(syspower.indexOf("'")!=-1)
- {
- System.out.println("syspower中含有非法字符!");
- return false;
- }else
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public boolean userNotExit(String user)
- {
- try{
- DBConn userDBConn = new DBConn();
- userDBConn.executeQuery("select * from sysadmin where UserID='" + user + "'");
- if(userDBConn.rs_next())
- {
- System.out.println("用户名已存在,请选择其它的用户名!");
- return false;
- }else
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public int getNewID()
- {
- try{
- DBConn newIDDBConn = new DBConn();
- newIDDBConn.executeQuery("select * from sysadmin order by ID desc limit 1");
- if(newIDDBConn.rs_next())
- {
- this.newID = newIDDBConn.rs_getInt("ID") + 1;
- System.out.println(this.newID);
- }else{
- this.newID = 1;
- }
- return this.newID;
- }catch(Exception e){
- System.out.println(e.toString());
- return -1;
- }
- }
- public int getID()
- {
- return this.newID;
- }
- public boolean register(String ID,String username,String password,String confirm,String syspower)
- {
- try{
- DBConn regDBConn = new DBConn();
- String strSQL = "insert into sysadmin(ID,UserID,Passwd,syspower) values('" + this.newID +"','" + username + "','" + password + "','" + syspower + "')";
- regDBConn.execute(strSQL);
- return true;
- }catch(Exception e){
- System.out.println(e.toString());
- return false;
- }
- }
- public static void main(String args[])
- {
- try{
- reg newreg = new reg();
- System.out.println(newreg.reg("ssssssss","sssssssss","ssssss","ssssss","ssssssss"));
- DBConn myconn = new DBConn();
- myconn.executeQuery("select * from sysadmin");
- while(myconn.rs_next())
- {
- System.out.println(myconn.rs_getInt("ID") + " " + myconn.rs_getString("UserID") + " " + myconn.rs_getString("Passwd") + " " + myconn.rs_getString("syspower"));
- }
- System.out.println(newreg.getID());
- }catch(Exception e){
- System.err.println(e.toString());
- }
- }
- };