jsp网上书店网页设计 第5页
Statement sql=null;
ResultSet rs=null;
// try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); }
// catch(ClassNotFoundException event){}
try {
Connection con;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:shop","root","123456");
sql=con.createStatement();
/*
String query="SELECT username FROM users";
rs = sql.executeQuery(query);
username=rs.getString(2);
if(username.value == "username") out.print("该用户名已经存在!");
else */
//{
String query="SELECT id FROM users";
rs = sql.executeQuery(query);
while (rs.next())
{ id=rs.getString(1);
}
if (id.equals("")) id="1";
else{
int tmp=Integer.parseInt(id);
tmp++;
Integer t=new Integer(tmp);
id=t.toString();
}
out.println("恭喜您!你是成功注册本站的第"+id+"用户!");
// }
String insert=
"INSERT INTO users(username,realname,password,email,phone,address) VALUES"+"('"+username+"','"+realname+"','"+password+"','"+email+"','"+phone+"','"+address+"')";
sql.executeUpdate(insert); //执行添加操作:
}
catch(SQLException event)
{ }
// }
// else {out.print("<BR>"+"该名字已经存在,请您换个名字");
// }
%>
<a href="index.jsp">返回首页>></a></div>
五.
public synchronized void putString(String s)
{ hashtable.put(s,s);
}
%>
<% String person_name=request.getParameter("name"),
name_found=null;
if(person_name==null)
{person_name="";
}
byte b[]=person_name.getBytes("ISO-8859-1");
person_name=new String(b);
name_found=(String)hashtable.get(person_name);
if(name_found==null)
{ String person_email=request.getParameter("address");
if(person_email==null)
{person_email="";
}
StringTokenizer fenxi=new StringTokenizer(person_email," @");
int n=fenxi.countTokens();
if(n>=3)
{out.print("<BR>"+"你输入的Email有不合法字符");
}
else
{ putString(person_name);
out.print("<BR>"+"您已经注册成功");
out.print("<BR>"+"您注册的名字是"+person_name);
}
}
else
{out.print("<BR>"+"该名字已经存在,请您换个名字");
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
jsp网上书店网页设计 第5页下载如图片无法显示或论文不完整,请联系qq752018766