The JSP connects directly to the SQL2008 database and displays

Source: Internet
Author: User
Tags stmt

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.