How to achieve clustering and connection pooling in ejb

Questions by jyoti_das16

Showing Answers 1 - 2 of 2 Answers

Supraja

  • Feb 28th, 2006
 

To achieve clustering : You need to configure vendor specific deployment descriptor file(or other vendor specific manner) in order to get cluster aware EJB application. When you configure for clustering, EJB Container/Server generates cluster aware EJBeans. Look at vendor specific documentation for details on clustering. So use clustering to get high scalability and fail over.

  Was this answer useful?  Yes

Supraja

  • Feb 28th, 2006
 

For ConnectionPool

Example for weblogic

<JDBCConnectionPool
  CapacityIncrement="1"
  DriverName="com.pointbase.xa.xaDataSource"
  InitialCapacity="2" MaxCapacity="10"
  Name="demoXAPool" Password="password"
  Properties="user=examples;
    DatabaseName=jdbc:pointbase:server://localhost/demo"
  Targets="examplesServer"
SecondsToTrustAnIdlePoolConnection="15"
  TestConnectionsOnreserve="true"
 
TestTableName="SYSTABLES"
  URL="jdbc:pointbase:server://localhost/demo"
/>

 

 

Dynamic Connection Pool Sample Code

The following sections show code samples for performing the main steps to create a connection pool dynamically.

Import Packages

import java.sql.*;
import java.util.*;
import javax.naming.Context;
import javax.sql.DataSource;
import weblogic.jndi.Environment;
import weblogic.management.configuration.JDBCConnectionPoolMBean;
import weblogic.management.runtime.JDBCConnectionPoolRuntimeMBean;
import weblogic.management.configuration.JDBCTxDataSourceMBean;
import weblogic.management.configuration.ServerMBean;
import weblogic.management.MBeanHome;
import weblogic.management.WebLogicObjectName;
String cpName = null;
String cpJNDIName = null;

Look Up the Administration MBeanHome

mbeanHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

Get the Server MBean

svrAdminMBean = (ServerMBean)adminMBeanHome.getAdminMBean("myserver",
"Server");

Create the Connection Pool MBean

  // Create ConnectionPool MBean
cpMBean = (JDBCConnectionPoolMBean)mbeanHome.createAdminMBean(
cpName, "JDBCConnectionPool",
mbeanHome.getDomainName());

Set the Connection Pool Properties

  Properties pros = new Properties();
pros.put("user", "scott");
pros.put("server", "dbserver1t1");
  // Set DataSource attributes
cpMBean.setURL("jdbc:weblogic:oracle");
cpMBean.setDriverName("weblogic.jdbc.oci.xa.XADataSource");
cpMBean.setProperties(pros);
cpMBean.setPassword("tiger");

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions