1<%@ page contenttype= "text/html; Charset=utf-8 "language=" java "errorpage=" "%>2<%@ pageimport= "Java.sql.*"%>345<title> Welcome </title>67<%!8PublicintCount=0;9 Public String info ()Ten { One return"Hello"; A } -%> -<body> the<% -Class.forName ("Com.microsoft.sqlserver.jdbc.SQLServerDriver") ; -Connection conn = drivermanager.getconnection ("Jdbc:sqlserver://localhost:1433;databasename=qhy", "sa", "sa"); -Statement stmt =conn.createstatement (); +ResultSet rs = stmt.executequery ("SELECT * from T_users"); -%> +<table bgcolor= "#9999dd" border= "1" width= "300px" > A<% at while(Rs.next ()) - { -%> -<tr> -<td> Cyclic value:</td> -<td><%=rs.getstring (1)%></td> in<td><%=rs.getstring (2)%></td> -</tr> to<% + } -%> the</table> *</body> $To first download the JDBC driver and put it in the Lib or project Lib of Tomcat;
The JSP connects directly to the SQL2008 database and displays