下面是一下参数的必要说明:
1) description 对被引用的资源的描述。
2) res-ref-name 资源名称。见上面的<ResourceParams name="jdbc/toni">
3) res-type 资源类型。见上面的<Resource name="jdbc/toni" auth="Container" type="javax.sql.DataSource"/>
在程序中使用的方法与其他的应用大体相同。
Context ctx=null;
Connection cnn=null;
ctx=new InitialContext();
if(ctx==null)
throw new Exception("没有匹配的环境");
DataSource ds=(DataSource)ctx.lookup(url);
if(ds==null)
throw new Exception("没有匹配数据库");
cnn=ds.getConnection();
return cnn;
上一页 [1] [2] [3] [4] [5]
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18