Tomcat  context{
 <Resource name="jdbc/master" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="5000" username="sa" password="123" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;databaseName=master" /> 
}
index.jsp{  
 <%
   Context ctx=new InitialContext();
 DataSource envCtx = (DataSource) ctx.lookup("java:comp/env/jdbc/master");
 Connection conn=envCtx.getConnection();
    out.print(conn);
    %>}
打印结果:{
jdbc:sqlserver://localhost:1433;responseBuffering=full;encrypt=false;databaseName=master;selectMethod=direct;trustServerCertificate=false;lastUpdateCount=true;, UserName=sa, Microsoft SQL Server 2005 JDBC Driver 
}
新手分少 ,就给2分了,谢谢高手 解决!

解决方案 »

  1.   

    打印 Connection 是jdbc:sqlserver://localhost:1433;responseBuffering=full;encrypt=false;databaseName=master;selectMethod=direct;trustServerCertificate=false;lastUpdateCount=true;, UserName=sa, Microsoft SQL Server 2005 JDBC Driver应该是 com.microsoft.sqlserver.jdbc.SQLServerStatement@2b7632   的东西吧  刚刚学连接池 不怎么懂
      

  2.   

    那个好像是反射的信息!
    用Properties可以得出准确的数据信息!
      Context ctx=new InitialContext(); 
      DataSource envCtx = (DataSource) ctx.lookup("java:comp/env/jdbc/master"); 
      Connection conn=envCtx.getConnection(); 
         if(conn !=null){
         System.out.pringln("get a connection successful...")
      }先看你的连接成功不!