• JDBC


    JDBC代码

            private static final long serialVersionUID = 1L;
            public static final String DBDRIVER="com.mysql.jdbc.Driver";//org.gjt.mm.mysql.Driver
            public static final String DBURL="jdbc:mysql://localhost:3306/test";
            public static final String DBUSER="root";
            public static final String DBPASS="";       

            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();
                }
            }

    。。。

  • 相关阅读:
    女子腰背疼痛案
    老人心悸心膝部无力屈伸不利案
    经方生姜泻心汤临床应用发挥
    电话求诊易误治
    女子乳房结块案
    小儿手足口案
    门纯德老先生经验
    男子肋部掣痛案
    加味潜降汤治疗阴虚阳亢之眩晕(来自网络)
    三叉神经痛与芎胡六虫汤
  • 原文地址:https://www.cnblogs.com/bluewhy/p/4950285.html
Copyright © 2020-2023  润新知