Forum Stats

  • 3,769,028 Users
  • 2,252,898 Discussions
  • 7,874,843 Comments

Discussions

Storing Arraylist Values into database from java class ??

Kashif Ali
Kashif Ali Member Posts: 469
edited Jul 12, 2016 1:15PM 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 Jul 12, 2016 7:26AM

    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 Jul 12, 2016 1:15PM
    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.