在jsp中如何连接数据库的事例
<%
java.sql.Connection conn;
java.sql.Statement stmt;
java.sql.ResultSet rs;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/joke?user=root");
stmt = conn.createStatement();
rs=stmt.executeQuery("select * from secondnews");
while(rs.next())
{
%>
<%=rs.getString(1)%>
<%=rs.getString(2)%><br>
<%
}
rs.close();
stmt.close();
conn.close();
%>
Jason
2004-12-06 19:05:49
评论:0
阅读:1632
引用:0
