jsp+连接MYSQL5.1

jsp+连接MYSQL5.1
<%
        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  />
        <%
        }
        %>
jsp+连接MYSQL5.1

jsp+连接MYSQL5.1,布布扣,bubuko.com

jsp+连接MYSQL5.1

上一篇:[转]Working with Parameters and Return Codes in the Execute SQL Task


下一篇:PHP Header下载文件在IE文件名中文乱码问题