惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
小众软件
小众软件
S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
罗磊的独立博客
有赞技术团队
有赞技术团队
V
V2EX
Y
Y Combinator Blog
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Fortinet All Blogs
W
WeLiveSecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
S
Security @ Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
PCI Perspectives
PCI Perspectives
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Security Latest
Security Latest
AWS News Blog
AWS News Blog
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
博客园 - Franky
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
N
News and Events Feed by Topic
Cloudbric
Cloudbric
Scott Helme
Scott Helme
云风的 BLOG
云风的 BLOG
Attack and Defense Labs
Attack and Defense Labs

博客园 - flyfish

Microsoft SQL Server 2005 -- 错误 29503。SQL Server 服务无法启动 模拟鼠标移动和左键单击 .C# 获取另一程序控件,改变值,触发事件 - flyfish - 博客园 在ASP程序中调用Web Service ASPNET2.0中读写Cookie的方法! - flyfish - 博客园 转 跨域读取Cookie和session之HttpWebRequest另类方法(网站API开发) ASP.NET WAP开发 用ASP.NET创建移动Web窗体[转] ASP.NET 2.0移动开发入门之使用模拟器 [WAP]dotNet在WAP应用开发中实现按指定页数翻页的解决方案 SQL Server 自增字段归零等问题 ntext replace sql SQLServer2005数据库还原到SQLServer2000 如何去除Google搜索结果病毒提示 Windows 2003远程桌面连接数限制 如何用SQL命令修改字段名称 FCKeditor详细的设置 log4net 配置与应用 两个sql server 2000的通用分页存储过程
Tomcat 6 连接 MS SQL 2005
flyfish · 2008-12-07 · via 博客园 - flyfish

http://www.javaworld.com.tw/jute/post/view?bid=9&id=232409&sty=3

 
<Context docBase="CallCenter" path="/CallCenter" reloadable="true" source="org.eclipse.jst.jee.server:CallCenter">
            <Resource
            name="jdbc/MsSQLDB"
            driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
            maxActive="100"
            maxIdle="30"
            maxWait="10000"
            username="sa"
            password="xxxxxx"
            type="javax.sql.DataSource"
            url="jdbc:sqlserver://localhost:1433;database=資料庫名稱;" />
            </Context>

(2)web.xml設定內容


            
<resource-ref>
            <description>JNDI JDBC DataSource of uopint</description>
            <res-ref-name>jdbc/MsSQLDB</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
            

(3)servlet連線程式部份

  

            Connection con = null;
            PreparedStatement stmt = null;
            Context initContext = new InitialContext();
            Context envContext = (Context)initContext.lookup("java:/comp/env");
            DataSource ds = (DataSource)envContext.lookup("jdbc/MsSQLDB");
            con = ds.getConnection();
            
            

五、SQL Server 2005相關設定
http://denistek.blogspot.com/2008/07/configure-tomcat-6-datasource-using-sql.html
This is a step-by-step instructions on how to configure Tomcat 6 DataSource using Sql Server 2005. The installation of Tomcat and SqlServer is not covered.
1. Verify that you can login to the SQL Server using 'SQL Server Authentication'. You may wish to change the 'Server Authentication mode' to 'SQL Server and Windows Authentication mode'. You may also wish to check that the particular user's status of Login is 'Enabled'.
2. Verify that 'Local and remote connections' is enabled.
Go to Microsoft SQL Server 2005>Configuration Tools>SQL Server Surface Area Configuration(SQL Server 外围应用配置器)>Remote Connections: Enable TCP/IP
3. Restart the database

四. Write a testing JSP page like this:
<%@   page   contentType="text/html;charset=UTF-8" %>  
<%@   page   import="java.sql.*" %>
<%@   page   import="javax.sql.*" %>
<%@   page   import="javax.naming.*" %>
<HTML>
<HEAD>
<TITLE>JSP example</TITLE>
</HEAD>
<BODY>
  <h1>Hello,test JNDI !  </h1>
  <%
    Context ctx = new InitialContext(); 
    Context envctx =  (Context) ctx.lookup("java:comp/env");
    DataSource ds =  (DataSource) envctx.lookup("jdbc/MsSQLDB"); 
    Connection  conn=ds.getConnection();  
    Statement  st=conn.createStatement();
    String    sql="select * from status"; 
    ResultSet    rs=st.executeQuery(sql);
    while(rs.next())   {
  %>  
  ID:<%=rs.getInt(1) %> 
       Value:<%=rs.getString(2) %>
       <br>
  <%
   }
  %>  
  Here is just JNDI datasource SQL Server 2005 + tomcat example
  <%
   rs.close();
   st.close(); 
   conn.close();  
  %>
</BODY>
</HTML>
按照上面的设置,就可以用 Tomcat 6 连接池 连接到 MS SQL 2005了