<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jsp 连接数据库应用</title>
</head>
<body>
<%
String url="jdbc:mysql://localhost:3306/ygtest"; //MYSQL 服务器的地址
String user="root"; //MYSQL 数据库的登录用户名
String pass="root"; //MYSQL 数据库的登录密码
String port="3306"; //SQL Server 服务器的端口号,默认为1433
Class.forName("com.mysql.jdbc.Driver");
Connection conn= DriverManager.getConnection(url,user,pass);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from news ");
while(rs.next()){
%>
<b>title1</b>
<%=rs.getString(2)%>
<b>内容</b>
<%=rs.getString(3)%>
<%
}
st.executeUpdate("update news set remark='ppppppppppppppp' where new_id=1");
%>