连接池的配置在7.1

本文介绍了一种使用WebLogic管理类动态创建和删除数据库连接池的方法,通过Java代码实现控制台的功能,适用于7.1及更高版本。
 该问题我们也折磨了好久:后来才发现解决办法:使用weblogic提供的管理类,可以完成console完成的任何功能,下面提供一端代码:[注意:连接池的配置在7.1后与web与EJB的配置完全不一样,包括加载服务的事件监听]
//动态产生连接池的类
import   java.sql.Connection;
import   java.sql.SQLException;

import   java.util.Iterator;
import   java.util.Set;
import   java.util.Properties;

import   javax.naming.Context;
import   weblogic.jndi.Environment;
import   weblogic.management.configuration.JDBCConnectionPoolMBean;
import   weblogic.management.configuration.ServerMBean;
import   weblogic.management.MBeanHome;


public   class   DynamicConnectionPoolHelper
{
private   Context   ctx   =   null;

private   MBeanHome   mbeanHome   =   null;
private   ServerMBean   serverMBean   =   null;

//   Connection   Pool
private   JDBCConnectionPoolMBean   myConnectionPool   =   null;

//   DataBase   attributes
private   String   dbUsername   =   "louis ";
private   String   dbPassword   =   "louis ";
private   String   dbURL   =   "jdbc:weblogic:mssqlserver4 ";
private   String   dbDriverName   =   "weblogic.jdbc.mssqlserver4.Driver ";

//   Security   credentials
private   String   password   =   null;
private   String   serverName   =   "myserver ";
private   String   url   =   null;
private   String   userName   =   null;

//产生一个连接池
public   JDBCConnectionPoolMBean   createConnectionPool(String   pNameOfConnectionPool)   throws   SQLException
{
System.out.println( "Creating   Connection   Pool... ");
try
{
//   Get   context
url   =   "t3://127.0.0.1:7001 ";
userName   =   "louis ";
password   =   "louisyyy ";
Environment   env   =   new   Environment();
env.setProviderUrl(url);
env.setSecurityPrincipal(userName);
env.setSecurityCredentials(password);
ctx   =   env.getInitialContext();

this.mbeanHome   =   (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
this.serverMBean   =   (ServerMBean)mbeanHome.getAdminMBean(serverName,   "Server ");

//   Get   a   set   of   JDBC   connection   pools   for   this   Domain.
//   Test   whether   the   connection   pool   exists   first   and   if   it   does,   delete   it.
Set   connectionPools   =   mbeanHome.getMBeansByType( "JDBCConnectionPool ",   mbeanHome.getDomainName());

Iterator   iter   =   connectionPools.iterator();
System.out.println( "Looping   through   all   connection   pools... ");
while   (iter.hasNext())
{
JDBCConnectionPoolMBean   aConnectionPool   =   (JDBCConnectionPoolMBean)iter.next();
System.out.println(aConnectionPool.getName());
if   (aConnectionPool.getName().equals(pNameOfConnectionPool))
{
this.deleteConnectionPool(aConnectionPool);
break;
}
}
//   Create   Connection   Pool
myConnectionPool   =   (JDBCConnectionPoolMBean)mbeanHome.createAdminMBean(pNameOfConnectionPool,   "JDBCConnectionPool ",   mbeanHome.getDomainName());

System.out.println( "Creating   Connection   Pool:   "   +   pNameOfConnectionPool);

Properties   props   =   new   Properties();
props.put( "user ",   this.dbUsername);
props.put( "password ",   this.dbPassword);
props.put( "server ",   "127.0.0.1:1034 ");

myConnectionPool.setURL(this.dbURL);
myConnectionPool.setDriverName(this.dbDriverName);
myConnectionPool.setProperties(props);

//   Target   the   Connection   Pool   to   the   specified   server.
myConnectionPool.addTarget(serverMBean);
System.out.println( "Starting   up   connection   pool. ");
return   myConnectionPool;
}
catch   (Exception   e)
{
throw   new   SQLException(e.toString());
}
}
//删除一个连接池
public   void   deleteConnectionPool(JDBCConnectionPoolMBean   pConnectionPoolMBean)   throws   SQLException
{
System.out.println( "Deleting   Connection   Pool... ");
try
{
//   Remove   Connection   Pool   from   the   server
pConnectionPoolMBean.removeTarget(serverMBean);

//   Remove   Connection   MBean   from   the   configuration
mbeanHome.deleteMBean(pConnectionPoolMBean);

}
catch   (Exception   ex)
{
throw   new   SQLException(ex.toString());
}
}
}
源码来自:https://pan.quark.cn/s/41b9d28f0d6d 在信息技术领域中,jQuery作为一个广受欢迎的JavaScript框架,显著简化了诸多操作,包括对HTML文档的遍历、事件的管理、动画的设计以及Ajax通信等。 本篇文档将深入阐释如何运用jQuery达成一个图片自动播放的功能,这种效果常用于网站的轮播展示或幻灯片演示,有助于优化用户与页面的互动,使网页呈现更加动态的视觉体验。 为了有效实施这一功能,首先需掌握jQuery的核心操作。 通过$符号作为接口,jQuery能够迅速选取DOM组件,例如$("#id")用于选取具有特定ID的元素,而$(".class")则能选取所有应用了某类class的元素。 在选定元素之后,可以执行多种行为,诸如事件监听、样式的变更、内容的更新以及动画的制作等。 关于“一个基于jQuery的图片自动播放功能”,首要任务是准备一组图片素材,这些素材将被整合至一个容器元素之中。 例如,可以构建一个div元素,将其宽度设定为单张图片的尺寸,再借助CSS实现溢出内容的隐藏,从而构建出水平滚动的初始框架。 ```html<div id="slider"> <img src="image1.jpg" alt="Image 1"> <img src="image2.jpg" alt="Image 2"> <!-- 更多图片内容... --></div>```接着,需要编写jQuery脚本以实现图片的自动切换。 这通常涉及到定时器的运用,以设定周期性间隔自动更换当前显示的图片。 通过使用`.fadeOut()`和`.fadeIn()`方法,能够实现图片间的平滑过渡,增强视觉效果。 ```javascript$(document).re...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值