新人java web数据库求助
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" import="java.sql.*,java.io.*,java.util.*"%>
<%@ page contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>关于我们</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<div align=center><b>滚动公告</b></div>
<table cellspacing=0 cellpadding=1 width="100%" border=0>
<tr><th bgcolor=#CCCCCC><marquee direction=up height=120 width=260 id=m onmouseout=m.start() onMouseOver=m.stop() scrollamount=2 >
<% //驱动程序名
String driverName = "com.mysql.jdbc.Driver";
//数据库用户名
String userName = "root";
//密码
String userPasswd = "";
//数据库名
String dbName = "sx";
//表名
String tableName = "news";
//联结字符串
String url = "jdbc:mysql://localhost:3306/" + dbName + "?user="
+ userName + "&password=" + userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql = "SELECT news_name FROM " + tableName;
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) { %>
<p><% out.print(rs.getString(1)); %></p>
<p><% out.print(rs.getString(2)); %></p>
<p><% out.print(rs.getString(3)); %></p>
<p><% out.print(rs.getString(4)); %></p>
<% }
rs.close();
statement.close();
connection.close();
%>
</marquee></th>
</tr>
</table>
<div align=center><b>具体内容</b></div>
<p> 此处应该获取上面的具体内容</p>
</body>
</html>
这是源代码
我想要
<p><% out.print(rs.getString(1)); %></p>
<p><% out.print(rs.getString(2)); %></p>
<p><% out.print(rs.getString(3)); %></p>
<p><% out.print(rs.getString(4)); %></p>
获取数据库中的信息 可是出现报错此处
该怎么修改
谢谢各位大佬