• jsp连接Sql2008


    <%@ page language="java" contentType="text/html; charset=gb2312"
     pageEncoding="gb2312" import="java.sql.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>jsp连接Sql2008</title>
    </head>
    <body>
     <center>

       <%
        String url = "jdbc:sqlserver://localhost:1433; DatabaseName=JavaJdbc";
        String user = "sa";
        String password = "110";
        Connection conn = null;
        PreparedStatement pstmt = null;
        
        String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
        try {
         
         Class.forName(driverName).newInstance();
        
         conn = DriverManager.getConnection(url, user, password);
      
        } catch (ClassNotFoundException e) {
         out.println(e);
        } catch (SQLException e) {
         out.println("连接SQLserver数据库失败!!!!!!");
        }
          if(pstmt!=null){
          pstmt.close();
          pstmt=null;
         }
         if(conn!=null){
          conn.close();
          conn=null;
         }
        }catch(Exception e){
         out.println("数据库关闭异常!");
        }
        out.println("insert成功!");
       %>
     </center>
    </body>
    </html>

  • 相关阅读:
    iOS多线程_06_GCD其它用法
    iOS多线程_05_线程间通信NSThread/GCD
    iOS多线程_04_GCD
    iOS多线程_03_Block
    iOS多线程_02_多线程的安全问题
    iOS多线程_01_简介和NSThread
    shell 根据端口号输出所有的pid
    【java核心36讲】接口和抽象类的区别
    CSS布局
    CSS基础
  • 原文地址:https://www.cnblogs.com/atwanli/p/2771671.html
Copyright © 2020-2023  润新知