zoukankan      html  css  js  c++  java
  • 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();
                }
            }

    。。。

  • 相关阅读:
    本学期课程总结
    “进度条”博客——第十六周
    “进度条”博客——第十五周
    《梦断代码》阅读笔记03
    第二期冲刺站立会议个人博客16(2016/6/09)
    第二期冲刺站立会议个人博客15(2016/6/08)
    第二期冲刺站立会议个人博客14(2016/6/07)
    第二期冲刺站立会议个人博客13(2016/6/06)
    第二期冲刺站立会议个人博客12(2016/6/05)
    “进度条”博客——第十四周
  • 原文地址:https://www.cnblogs.com/bluewhy/p/4950285.html
Copyright © 2011-2022 走看看