时间: 2021-07-31 作者:daque
六、jsp贯穿mysql数据库 testmysql.jsp如次: <%@ page contenttype="text/html;charset=utf8"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("org.gjt.mm.mysql.driver").newinstance(); string url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useunicode=true&characterencoding=8859_1" //testdb为你的数据库名 connection conn= drivermanager.getconnection(url); statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); string sql="select * from test"; resultset rs=stmt.executequery(sql); while(rs.next()) {%> 您的第一个字段实质为:<%=rs.getstring(1)%> 您的第二个字段实质为:<%=rs.getstring(2)%> <%}%> <%out.print("数据库操纵胜利,祝贺你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html>