时间: 2021-07-31 作者:daque
五、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>