<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

                    J2EE Bad Practices: getConnection()

                    ABSTRACT

                    J2EE 標準禁止對連接實行直接管理。

                    EXPLANATION

                    J2EE 標準要求應用程序采用容器的資源管理器工具獲取連接資源。

                    例如,一個 J2EE 應用程序應采用下列方式獲取數據庫連接:


                    ctx = new InitialContext();
                    datasource = (DataSource)ctx.lookup(DB_DATASRC_REF);
                    conn = datasource.getConnection();


                    并避免采用下列方式獲取連接:


                    conn = DriverManager.getConnection(CONNECT_STRING);


                    每個主要的 Web 應用程序容器都提供了數據庫連接管理,并將其作為資源管理框架的一部分。在應用程序中重寫這個功能,其過程既復雜又容易出錯,這也是 J2EE 標準禁止這種行為的原因之一。

                    REFERENCES

                    [1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 245

                    [2] Java 2 Platform Enterprise Edition Specification, v1.4 Sun Microsystems


                    Copyright 2013 Fortify Software - All rights reserved.
                    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
                    desc.semantic.java.j2ee_badpractices_getconnection

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频