package a1;
import java.sql.*;
public class Register
{   String logname,
           realname,
           password,
           email,
           phone,
           address;
    String message; 
    Connection con;
    Statement sql; 
    ResultSet rs;
    public Register()
    {  //加载桥接器：
       try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          }
       catch(ClassNotFoundException e){}
    }
  //设置属性值、获取属性值的方法：
   public void setLogname(String name)
    {  logname=name;
    }
   public String getLogname()
    {return logname;
    }
   public void setRealname(String name)
    {  realname=name;
    }
    public String getRealname()
    {return realname;
    }
   public void setPassword(String pw)
    {  password=pw;
    }
    public String getPassword()
    {return password;
    }
   public void setEmail(String em)
    {  email=em;
    }
    public String getEmail()
    {return email;
    }
   public void setPhone(String ph)
    {  phone=ph;
    }
   public String getPhone()
    {return phone;
    }
   public void setAddress(String ad)
    {  address=ad;
    }
   public String getAddress()
    {return address;
    }
   public String getMessage()
    {return message;
    } 
   //添加记录到数据库的user表：
   public void addItem()
    {try{
        con=DriverManager.getConnection("jdbc:odbc:shop","","");
        sql=con.createStatement();
        String s=
        "'"+logname+"'"+","+"'"+realname+"'"+","+"'"+password+"'"+","+"'"+
          email+"'"+","+"'"+phone+"'"+","+"'"+address+"'";
        String condition="INSERT INTO user VALUES"+"("+s+")";
        sql.executeUpdate(condition);
        message="注册成功了";
        con.close();
       }
     catch(SQLException e)
       {message="你还没有注册，或该用户已经存在，请你更换一个名字";
       }
    }
}