java web 程序---jsp连接mysql数据库的实例基础+表格显示
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<center>JSP连接mysql数据库</center>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=123");
Statement stm=conn.createStatement();
//stm.executeUpdate("insert into shop values ('男','林俊杰','323')");
ResultSet rs=stm.executeQuery("select * from shop");
out.print("<table border='1'>");
out.print("<tr><td>性别:</td><td>姓名:</td><td>密码:</td></tr>");
while(rs.next()){
out.print("<tr>");
out.print("<td>"+rs.getString("sex")+"</td>");
out.print("<td>"+rs.getString("name")+"</td>");
out.print("<td>"+rs.getString("pass")+"</td>");
out.print("</tr>");
}
out.print("</table>");
%>
</body>
以上是 java web 程序---jsp连接mysql数据库的实例基础+表格显示 的全部内容, 来源链接: utcz.com/z/394517.html