打印本文 打印本文 关闭窗口 关闭窗口
Tomcat配置SQLServer连接池
作者:武汉SEO闵涛  文章来源:敏韬网  点击数10934  更新时间:2007/11/14 12:59:40  文章录入:mintao  责任编辑:mintao
driverClassName=" com.microsoft.jdbc.sqlserver.SQLServerDriver "

            url=" jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=KB_Rate""/>

 

 

</Context>

 

 

配置完成后,DBTest目录下添加一个Test文件,如下:

<%@ page contentType="text/html;charset=gb2312"%>

<%@ page import="java.sql.*"%>

<%@ page import="javax.sql.*"%>

<%@ page import="javax.naming.*"%>

<%

  Connection conn = null;

  Context initCtx = new InitialContext();

  if (initCtx == null)

     throw new Exception("不能获取Context!");

      Context ctx = (Context) initCtx.lookup("java:comp/env");

      Object obj = (Object) ctx.lookup("/Default_JDBC ");//获取连接池对象

      javax.sql.DataSource ds = (javax.sql.DataSource) obj; //类型转换

      conn = ds.getConnection();

  Statement stmt = conn.createStatement();

  PreparedStatement ps=conn.prepareStatement("select * from FinalOrderdata");

  ResultSet rs=ps.executeQuery();

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口