• tomcat和WebSphere下JNDI是不同的


    public static Connection getConnection1() throws ServletException {
      Connection con = null;

      try {
       Context initCtx = new InitialContext();
                //tomcat中查找如下:  
       //DataSource ds = (DataSource)initCtx.lookup("java:/comp/env/jdbc/b2c");
       //websphere中查找如下:
       /////////////////////////////////////////////////////////////////////////
       DataSource ds = (DataSource)initCtx.lookup("jdbc/shopping");
       ////////////////////////////////////////////////////////////////////////
       con = ds.getConnection();
       System.out.println("数据源连接成功");   
      } catch (NamingException e) {
       e.printStackTrace();   
       throw new ServletException(e.getMessage());
      } catch (SQLException e) {
       e.printStackTrace();   
       throw new ServletException(e.getMessage());
      }
      return con;
     }

  • 相关阅读:
    计算机的基本存储单位
    挖坑
    HEOI2017 游记
    bzoj4815 [Cqoi2017]小Q的表格
    bzoj4817 [Sdoi2017]树点涂色
    hdu5824 graph
    4.5&4.7联考题解
    高飞
    无题
    51Nod 算法马拉松23 开黑记
  • 原文地址:https://www.cnblogs.com/luleiitlife/p/8545114.html
Copyright © 2020-2023  润新知