时间: 2021-07-31 作者:daque
四、jsp贯穿informix数据库 testinformix.jsp如次: <%@ page contenttype="text/html;charset=utf8"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("com.informix.jdbc.ifxdriver").newinstance(); string url = "jdbc:informix-sqli://123.45.67.89:1533/testdb:informixserver=myserver; user=testuser;password=testpassword"; //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> 五、jsp贯穿sybase数据库 testmysql.jsp如次: <%@ page contenttype="text/html;charset=utf8"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("com.sybase.jdbc.sybdriver").newinstance(); string url =" jdbc:sybase:tds:localhost:5007/tsdata"; //tsdata为你的数据库名 properties sysprops = system.getproperties(); sysprops.put("user","userid"); sysprops.put("password","user_password"); connection conn= drivermanager.getconnection(url, sysprops); 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> 六、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>七、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>(代码试验室)