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("已存在");
}}
本人认为这样简单一些,如果在添加的时候判断可能会很麻烦