UserLogic(username)
{
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
//连接数据库
ps=con.PreparedStatement("select * from 表 where username=?");
ps.setString(1,username)
rs=ps.executeQuery();
while(rs.next)
{
System.out.println("已存在");
}}
本人认为这样简单一些,如果在添加的时候判断可能会很麻烦
{
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
//连接数据库
ps=con.PreparedStatement("select * from 表 where username=?");
ps.setString(1,username)
rs=ps.executeQuery();
while(rs.next)
{
System.out.println("已存在");
}}
本人认为这样简单一些,如果在添加的时候判断可能会很麻烦
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货