Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement performance testing with JBoss EJB CMP2

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how JBoss EJB CMP2 implements performance testing. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Test environment

Operating system: Win2000

CPU:PIII733EB

Memory:512M

Application Server:JBoss-3.0.2

DBMS:SAP DB7.3

Java VM:JDK-1.4.1

Ant:1.5.1 [@ more@] Test Scheme 

* Table structure

Table: AUX_TYPE

COLUMN name SAP DB type Java type

AUX_ID (Primary Key) Integer Integer

AUX_DESC Varchar (50) String

Table: TEST_NEWS

COLUMN name SAP DB type Java type

TID Integer Integer

AUX_ID (Foreign key reference to AUX_TYPE (AUX_ID)) Integer Integer

TNAME Varchar (30) String

TDESC Varchar (100) String

AMOUNT Integer Integer

* EJB structure

Use an EntityBean with a local interface to establish a correspondence with the table. Use a stateless SessionBean to interact with the client. The role of SessionBean is to act as a proxy for EntityBean and to provide remote data access as a coarse-grained Bean. The maximum ID value of the table AUX_TYPE primary key is also provided by the SessionBean (using JDBC join) method. Some other EJB QL cannot be implemented, and special query methods for databases can also be implemented in SessionBean.

* Test the code

...

Private Category log = Category.getInstance (getClass ())

Private AuxTypeHome auxTypeHome = null

Private TestNewsHome testNewsHome = null

Private Context initial = null

Public void addNews (

Integer tId

String tName

String tDesc

Integer amount

String auxDesc) {

AuxType auxType = null

Try {

AuxType = auxTypeHome.findByDesc (auxDesc)

Log.info ("@" + auxType.getAuxDesc ())

If (auxType = = null)

Throw new EJBException ("AUX_TYPE is empty!")

} catch (FinderException e) {

Throw new EJBException ("findAuxType:" + auxDesc + "error!")

}

Try {

TestNews testNews = testNewsHome.create (tId, tName, tDesc, amount)

TestNews.setAuxType (auxType)

} catch (CreateException e) {

Throw new EJBException (

"create TestNews:" + tId + "," + tName + "error!"

}

}

Private Connection connection = null

Private DataSource source = null

Public synchronized int getNextId () throws RemoteException, SQLException {

Statement stmt = null

Int id =-1

Try {

If (initial = = null)

Initial = new InitialContext ()

If (source = = null)

Source = (DataSource) initial.lookup ("java:/SapdbDS")

If (connection = = null)

Connection = source.getConnection ()

Stmt = connection.createStatement ()

String sql = "select max (TID) from TEST_NEWS"

ResultSet rs = stmt.executeQuery (sql)

If (rs.next ()) {

Id = rs.getInt (1)

If (id

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report