主题:jdbc连接mysql怎么出现了空白页啊。。为什么啊。
程序代码如下:
<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.sql.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(ClassNotFoundException e){}
String url="jdbc:mysql://localhost/mysql?user=root&password=801009&useUnicode=true&characterEncoding=GB2312";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from mytest";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
<c:out value="数据库操作成功,恭喜你!"/>
<c:out value="rs.getString(1)"/>
<c:out value="rs.getString(2)"/>
<%}%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.sql.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(ClassNotFoundException e){}
String url="jdbc:mysql://localhost/mysql?user=root&password=801009&useUnicode=true&characterEncoding=GB2312";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from mytest";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
<c:out value="数据库操作成功,恭喜你!"/>
<c:out value="rs.getString(1)"/>
<c:out value="rs.getString(2)"/>
<%}%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>