Queries all data with SQL Server and displays

Source: Internet
Author: User

Use SQL Server to query the data and display all the data on the page.

<%@ Page Language="Java" Import="Java.util.*"Pageencoding="UTF-8"%><%@pageImport="Jdbc.sqlserver"%><%@pageImport="Java.sql.Connection"%><%@pageImport="Java.sql.Statement"%><%@pageImport="Java.sql.ResultSet"%><%String Path=Request.getcontextpath (); String BasePath=Request.getscheme ()+"://"+Request.getservername ()+":"+Request.getserverport ()+Path+"/";%><! DOCTYPE HTML Public"-//W3c//DTD HTML4.01Transitional//EN "><Html>  <Head>    <Base href="<%=BasePath%>">        <Title>My JSP'lindao.jsp'Starting page</Title>        <Meta HTTP-Equiv="Pragma" content="No-Cache>    <Meta HTTP-Equiv=The cache-Control "Content="No-Cache>    <Meta HTTP-Equiv="Expires" content="0">        <Meta HTTP-Equiv="keywords" content="Keyword1,keyword2,keyword3">    <Meta HTTP-Equiv="description" Content="This isMy Page ">    <!--    <Link rel="Stylesheet" type="text/CSS "href="Styles.css">    -->  </Head>    <Body>                           <!--Query Administrator Information --                 <Div>      <TableBorder=1px style="width:500px;height:200px;text-Align:center;margin:0Auto;margin-Top: 0px ">                <div style="Width:500px;height:40px;border:1px Solid Red;margin:0Autotext-Align:center;margin-Top: 60px;background: #fff; margin-Top:-2px ">                                    <Font Color="Red" font-Weight="Bold">Administrator Information</Font>                     </Div>      <TR Style="Background:red">                     <Td>Number</Td>           <Td>Name</Td>            <Td>Number of Ingot</Td>            <Td>Delete</Td>                      </Tr>          <%           //Reference Connection database method SQL Server SQ1=new SQL Server (); //Get database connection Connection Con1=sq1.getconnection (); //Write SQL statement String SQL1="Select *  fromAdmin "; //get Database object operations Statement ST1=con1.createstatement (); //get the results of the query ResultSet rs1=st1.executequery (SQL1);  while(Rs1.Next()){                       %> <Tr>             <Td> <%Out.Print(Rs1.getint (1)+"\ t");%></Td>                                        <Td> <%Out.Print(Rs1.getstring (2)+"\ t");%></Td>                                        <Td> <%Out.println (Rs1.getint (3)+"\ t");%></Td>             <Td> <a href="Time.jsp?id=<%Out.Print(Rs1.getint (1)+"\ t");%>">Delete</A></Td>            </Tr><%           }               //frees the resource sq1.          Shifang (Rs1,st1,con1); %>          </Table>    </Div>  </Body></Html>

Queries all data with SQL Server 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.