先贴段jsp代码试试
<%@ page contenttype="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html>
<body>
<%
string strname = "";
string strsex = "" ;
try
{
class.forname("com.mysql(和php搭配之最佳组合).jdbc.driver").newinstance();
string url = "jdbc:mysql(和php搭配之最佳组合)://localhost:3306/samp_db" ;
string struser = "root" ;
string strpasswd = "123" ;
connection conn = drivermanager.getconnection(url,struser,strpasswd) ;
statement stmt = conn.createstatement(resultset.type_scroll_insensitive,resultset.concur_updatable) ;
string strsql = "select * from student" ;
resultset rs = stmt.executequery(strsql) ;
while(rs.next())
{
strname = rs.getstring("name") ;
strsex = rs.getstring("sex") ;
out.print(strname) ;
out.println(strsex) ;
}
stmt.close() ;
conn.close() ;
}
catch(exception e)
{
e.printstacktrace() ;
}
%>
</body>
</html>
上一篇: 日本8大便利店品牌 全家便利店上榜 罗森便利店登顶
下一篇: JSP简单标签开发