⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servicelocator.java

📁 struts的一些用的书籍
💻 JAVA
字号:
package app18a.util;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ServiceLocator {

	private static ServiceLocator instance;
  private DataSource dataSource;
  
	static {
		instance = new ServiceLocator();
	}
	
	private ServiceLocator () {
	  Context context = null;   
  	    
	  try {
	  	context = new InitialContext();
	    dataSource = (DataSource) context.lookup("java:/comp/env/jdbc/myDataSource");
	  }
	  catch (NamingException e) {	
	    System.out.println(e.toString());
	  }
	}
	
	public static ServiceLocator getInstance() {
	    return instance;
	}
	
	public DataSource getDataSource() {
	    return dataSource;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -