0

We have one application in that we have 3 table in DB2 schema. I am using below query to fetch record. the transaction table may contain more than 1000000 records. I wrote below query to fetch data from multiple tables but it is taking more time than expectation of testers.

select * from (select ROW_NUMBER() OVER ( order by SOURCE_REFERENCE_NO,Trans_Date,Trans_Time,User_ID ) as RN ,Trans_Type from transaction t left join applicationref ar on t.code = ar.code left join user u on u.username = t.useraccess left join user u1 on u1.username = t.username )as w

Raj Gohel
  • 3
  • 6

2 Answers2

0

Technically, you can declare additional methods in your Servlet, but ideally you should encapsulate those business logic into Services and DAO (Data Access Object) as separate classes.

Ish
  • 3,992
  • 1
  • 17
  • 23
  • Yes that's true. I have to bind different method with different business logic .Can you give little bit more explanation? How to bind multiple action with single servlet. – Raj Gohel Oct 13 '15 at 17:43
0

I would add to Ish's answer.

Yes, you should define the actual business login in a separate service class or DAO but the actual call of this different business logic should be appropriately called in the Servlet itself.

The scheme that suits your requirement is creating a hidden action parameter in the form. Lets call it action. Check for this parameter in Servlet doGet or doPost method.

You can either use 'switch statement' if Java 1.8 or 'if else if' for any other version.

Something like this.

String action = request.getParameter('action');
if(action.equals('logic1')){
    service.businesslogic2();
} else if(action.equals('logic2')){
    service.businesslogic2();
} else if(action.equals('logic3'))
....
....
....

service is any service class instance.

Jafar Ali
  • 1,084
  • 3
  • 16
  • 39