JDBC代码
request.setCharacterEncoding("GBK");
response.setContentType("text/html");
Connection connection=null;
PreparedStatement preparedStatement=null;
ResultSet rSet=null;
PrintWriter out=response.getWriter();
String userid=request.getParameter("userid");
try {
Class.forName(DBDRIVER);
connection=DriverManager.getConnection(DBURL,DBUSER,DBPASS);
String sql="select count(userid) from user where userid=?";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, userid);
rSet=preparedStatement.executeQuery();
if(rSet.next()){
if(rSet.getInt(1)>0)
out.print("true");
else out.print("false");
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
finally{
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
。。。