• 一个测试SQL2005数据库连接JSP档


       在这里,在SQL 2005中间InterLib数据库案例。得到InterLib/tb_booktype目录。

    的影响,如下面的:

    其JSP代码例如以下:

    <%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>
    <%@ page import="java.util.*" %>
    <html>
      <head>
        <title>应用Statement对象查询数据</title>
      </head>
      
    <body>
          <%
          String driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver";
          String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=InterLib";
          String username = "admin";
          String password = "123456";
          Class.forName(driverClass);
          Connection conn=DriverManager.getConnection(url, username, password);
          Statement stmt = conn.createStatement();
          ResultSet rs = stmt.executeQuery("select * from tb_booktype");
           out.println("SQL2005连接成功!

    </p>"); out.println(" --- tb_booktype表中的内容例如以下:----"); while(rs.next()){ out.println("<br>编号: "+rs.getString(1)+" 书名:"+rs.getString(2)+" 价格:"+rs.getString(3)); } rs.close(); stmt.close(); conn.close(); %> </body> </html>



     

    版权声明:本文博主原创文章。博客,未经同意不得转载。

  • 相关阅读:
    中序遍历
    二叉树前序遍历
    A Real Stewart
    走遍美国 听写
    2016-12-12——2016-12-16友邻
    英语百日听力
    6.2分鱼问题两种解法
    Bootstrap组件1
    Bootstrap图标及另一个好用图标网站介绍
    Bootstrap全局CSS样式之图片
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4885994.html
Copyright © 2020-2023  润新知