Forum Stats

  • 3,728,154 Users
  • 2,245,559 Discussions
  • 7,853,357 Comments

Discussions

Storing Arraylist Values into database from java class ??

Kashif Ali
Kashif Ali Member Posts: 469
edited July 2016 in New To Java

Hi ever one i m using jdeveloper 11.1.2.3.0

My use case is i have 20 values in arraylist like

10

20

30

40

50

60.

.

..

.

.

and i need to store this arrayList into database table  from AppModuleImpl class (AppModuleImpl is a java class)??

kindly reply how i can do this

Thanks

Answers

  • 2838938
    2838938 Member Posts: 18
    edited July 2016

    Hi,

    ArrayList<Integer> arrl = new ArrayList<Integer>();

    //adding elements to the end

    arrl.add(60);

    arrl.add(20);

    arrl.add(30);

    arrl.add(40);

    Iterator<Integer> itr = arrl.iterator();

    while(itr.hasNext()){

        //write your db code

        System.out.println(itr.next()); // print arraylist values

      }

        ---- May this can help you.

  • Unknown
    edited July 2016
    Kashif Ali wrote:
    
    Hi ever one i m using jdeveloper 11.1.2.3.0
    My use case is i have 20 values in arraylist like
    10
    20
    30
    40
    50
    60.
    .
    ..
    .
    .
    
    and i need to store this arrayList into database table  from AppModuleImpl class (AppModuleImpl is a java class)??
    kindly reply how i can do this
    Thanks
    

    You do that by inserting rows one at a time  using the values in the collection.

    The JDBC Developer Guide discusses how to use JDBC and has example code.

    https://docs.oracle.com/database/121/JJDBC/E49300-05.pdf

This discussion has been closed.