Solved

Could you please modify my program to insert multiple records

Posted on 2011-02-26
4
259 Views
Last Modified: 2012-08-13
could you please modify my program to insert multiple records in Databas

could you please give me the code to insert multiple records using for loop,list and input DTO from junit test case          

 public  void testAdd() {
           System.out.println("testAdd");
                CustomBillerDTO inputDTO = new CustomBillerDTO();
                CustomBillerListDTO outputDTO = new CustomBillerListDTO();
                CustomBillerListDTO outputListDTO = new CustomBillerListDTO();
                List<CustomBillerDTO> arrInputList=new ArrayList<CustomBillerDTO>();
                AuditDTO auditDTO=new AuditDTO();
               // inputDTO.setLegalVehicleCode("LV17");
                inputDTO.setBillerCode("NSEL18");
                inputDTO.setBillUpLoadType("Y");
                inputDTO.setPayPressFlag("1");                
                auditDTO.setActiveStatusFlag("AA");                          
                auditDTO.setMakerCode("M");
                auditDTO.setCheckerCode("C");
                auditDTO.setWorkBranchCode("133");
                auditDTO.setChannelSource("1"); //ACC_CHA
                auditDTO.setMakerRemarks("MRE"); //ACC_MAKER
                auditDTO.setCheckerRemarks("CRE"); //ACC_CHEC
                inputDTO.setCurrentActiveStatusFlag("A");                      
                inputDTO.setAuditDTO(auditDTO);
                arrInputList.add(inputDTO);
                outputListDTO.setList(arrInputList);
                outputDTO=target.add(outputListDTO);
                System.out.println("Added");
                               }
            }

   
0
Comment
Question by:stmani2005
  • 2
4 Comments
 
LVL 8

Author Comment

by:stmani2005
ID: 34986294
above code to insert only one reocrd

give me the code to insert multiple records
0
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 34990355

Which sentence inserts the object into database? I cant find it, please expalin.

And what does JUnit have to do with all of this?
0
 
LVL 8

Author Comment

by:stmani2005
ID: 34994231
this code is insert the data into database

outputDTO=target.add(outputListDTO);
                System.out.println("Added");
0
 
LVL 3

Accepted Solution

by:
mehdi_javan earned 500 total points
ID: 34994718
It seems the following code is what you want:
public  void testAdd() {
	System.out.println("testAdd");
	CustomBillerListDTO outputDTO = new CustomBillerListDTO();
	CustomBillerListDTO outputListDTO = new CustomBillerListDTO();
	List<CustomBillerDTO> arrInputList=new ArrayList<CustomBillerDTO>();
	for(int i = 0; i < 10; i++) {
		CustomBillerDTO inputDTO = new CustomBillerDTO();
		AuditDTO auditDTO = new AuditDTO();
	   // inputDTO.setLegalVehicleCode("LV17");
		inputDTO.setBillerCode("NSEL18");
		inputDTO.setBillUpLoadType("Y");
		inputDTO.setPayPressFlag("1");                
		auditDTO.setActiveStatusFlag("AA");                          
		auditDTO.setMakerCode("M");
		auditDTO.setCheckerCode("C");
		auditDTO.setWorkBranchCode("133");
		auditDTO.setChannelSource("1"); //ACC_CHA
		auditDTO.setMakerRemarks("MRE"); //ACC_MAKER
		auditDTO.setCheckerRemarks("CRE"); //ACC_CHEC
		inputDTO.setCurrentActiveStatusFlag("A");                      
		inputDTO.setAuditDTO(auditDTO);
		arrInputList.add(inputDTO);
	}
	outputListDTO.setList(arrInputList);
	outputDTO=target.add(outputListDTO);
	System.out.println("Added");
}

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ArrayIndexOutOfBoundException 9 85
Java - Why doesn't this JFrame work 3 60
web services creation SOAP vs REST 5 42
oracle 11g 23 85
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question