谁能简明扼要的解释一下:连接池用到的几个技术的含义?(请不要引用长篇大论的东东)

qishiniandai 2004-04-30 04:23:28
如题,请参看下边的例子:
java.util.Properties parms = new java.util.Properties();
parms.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
javax.naming.Context ctx = new javax.naming.InitialContext(parms);
ds = (javax.sql.DataSource)ctx.lookup("comp/env/jdbc/emr");
conn = ds.getConnection();

1。java.util.Properties 干什么用的?对后边的语句的作用?

2。javax.naming.Context 叫什么上下文,究竟是什么意思,有什么用处?

3。ctx.lookup 是什么东东?

拜托诸位,如果给予解答,不要引用长篇大论的东东,谢谢

...全文
61 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hiking 2004-04-30
  • 打赏
  • 举报
回复
1. Properties is to keep some values with a certain index name. Such as: in csdn "hiking" means a certain user which names him/her as hiking. So if you want to find the certain user in csdn, just search hiking is ok.

2.InitialContext gets a value named javax.naming.Context.INITIAL_CONTEXT_FACTORY inside(extends from Context). And if inside the InitialContext needs the certain content value, then check the INITIAL_CONTEXT_FACTORY is OK.

3.javax.naming.Context is a special one. Cause there a lot of objects which will be used by uncertain customers. When a customer wants one of them, he/she requests the system and tells it what wanted. Then the system will search a list which is maintained by the middware applications. If matched, then the object is given the customer.(such as "java:comp/env/jdbc/emr")

4.customer gets the object and demarshels it to the suitable type and uses id.
qishiniandai 2004-04-30
  • 打赏
  • 举报
回复
谢谢诸位,^_^, daimin78(钻石人) 讲的也很精辟,我基本上明白了是怎么回事了,好了,50分,你们俩分了,谢谢啊!
daimin78 2004-04-30
  • 打赏
  • 举报
回复
java.util.Properties parms ,你可以把parms理解为文本文件指针,通过这个文件指针读取你在.xml文件的配置(resin里是resin.conf文件)

另外下面这句话要改一下,不然新手容易理解错误:
javax.naming.Context 是上下文环境,可以理解为初始化时必须的环境,有了这个环境你才能使用连接池 《-------------末尾改成:“有了这个环境你才能查找到连接池配置”
qishiniandai 2004-04-30
  • 打赏
  • 举报
回复
youthy_yy(希望我的回帖能对您有所帮助)的回复确实简明扼要,而且说的不错,感觉有了一些认识,不过parms这个变量,它从开始到结束扮演了一个什么样的角色?麻烦你再解释解释,嘿嘿,50分就给你了,你就好人好到底吧!
yaomengqiushui 2004-04-30
  • 打赏
  • 举报
回复
打算配个连接池,关注学习中。
youthy_yy 2004-04-30
  • 打赏
  • 举报
回复
java.util.Properties是一个类,它有getProperty和setProperty等方法,通常用于哈希表Hashtable,通过键值(Key)直接访问

javax.naming.Context 是上下文环境,可以理解为初始化时必须的环境,有了这个环境你才能使用连接池

ctx.lookup 很显然,lookup(寻找的意思),通过JNDI去找到对应的连接池
zhwquan 2004-04-30
  • 打赏
  • 举报
回复
主要是从jndi上去DataSource

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧