时间: 2021-07-31 作者:daque
七、jsp贯穿postgresql数据库 testmysql.jsp如次: <%@ page contenttype="text/html;charset=utf8"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("org.postgresql.driver").newinstance(); string url ="jdbc:postgresql://localhost/soft" //soft为你的数据库名 string user="myuser"; string password="mypassword"; connection conn= drivermanager.getconnection(url,user,password); 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>