cheng_you_know

学而时习之!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
<%
        String DBDriver = "org.gjt.mm.mysql.Driver";
        String DBUrl = "jdbc:mysql://localhost:3306/cheng_base";
        String DBUser = "root";
        String DBPassword = "cheng";
        Class.forName(DBDriver);
        Connection conn = null;
        try 
        {
            conn = DriverManager.getConnection(DBUrl,DBUser,DBPassword);
            out.println("数据库连接成功!");
        }
        catch(Exception ex)
        {
            //out.println("连接失败!");
            ex.printStackTrace();
            //return ;
        }
        Statement sqlStatement = conn.createStatement();
        String sql = "select * from cheng";
        ResultSet rs = sqlStatement.executeQuery(sql);
        while(rs.next())
        {
        %>
            <%=rs.getString(1)%>
            <%=rs.getString(2)%>
            你是 <%=rs.getString(3)%><br  />
        <%
        }
        %>
posted on 2014-03-05 13:06  cheng_you_know  阅读(147)  评论(0编辑  收藏  举报