Loading...

          java .net

          從weblogic連接池得到Connection

          public class Test {

              public static void main(String[] args) {
                  DataSource ds = null;
                  Context ctx = null;
                  Connection myConn = null;
                  try {
                      /*
                      * 獲得WebLogic ServerJNDI初始上下文信息
                      */
                      ctx = getInitialContext();
                      /*
                      * 建立數據源對象
                      */
                      ds = (javax.sql.DataSource) ctx.lookup("datasource");
                  } catch (Exception e) {
                      e.printStackTrace();
                  }

              }

              private static Context getInitialContext() throws Exception {
                  String url = "t3://localhost:7001";
                  String user = "";// 對應的weblogic管理名字
                  String password = "";// 密碼
                  Properties properties = null;
                  try {
                      properties = new Properties();
                      properties.put(Context.INITIAL_CONTEXT_FACTORY,
                              "weblogic.jndi.WLInitialContextFactory");
                      properties.put(Context.PROVIDER_URL, url);
                      if (user != null) {
                          properties.put(Context.SECURITY_PRINCIPAL, user);
                          properties.put(Context.SECURITY_CREDENTIALS,
                                  password == null ? "" : password);
                      }
                      return new InitialContext(properties);
                  } catch (Exception e) {
                      throw e;
                  }
              }

          }

          posted on 2008-08-26 22:06 閱讀(174) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 济南市| 祁阳县| 达孜县| 兴化市| 分宜县| 毕节市| 平度市| 曲靖市| 霍城县| 康定县| 海城市| 定襄县| 澳门| 乐清市| 铜山县| 南乐县| 安远县| 宣恩县| 巴东县| 虎林市| 迭部县| 白玉县| 烟台市| 余姚市| 莎车县| 丽江市| 石狮市| 白河县| 乳山市| 柞水县| 东宁县| 昭通市| 黄骅市| 仙游县| 揭西县| 阿坝县| 汶川县| 盐边县| 新竹市| 临汾市| 静安区|