Results 1 to 2 of 2
  1. #1
    frankycool is offline Member
    Join Date
    Nov 2009
    Rep Power

    Post Array Object to Database

    I have an arraylist As such :-

    products.add( new CarsSubProduct( "FordMustang",1,1000,10000 ) );

    FordMustang is Car name
    1 is Car number
    1000 is total number of cars in stock
    10000 is price per car

    I will like to Store it to access database or excel.Please how can these be done.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    Excel isn't a database, so I wouldn't use that.
    I'd hesitate to call Access one, but that's just me...;)

    Anyway, create a table in Access that matches your CarsSubProduct class, with columns defined for each of the attributes you want to store (name, number, etc). Then write some JDBC in your Java to make a series of INSERT calls for each car (looping round the array).

    There are preferred ways of doing that last bit (batching for example), but in your case it's probably best to just stick to a loop of individual INSERTs.

    Look at the Sun JDBC tutorial, which'll give you the basics for doing all that.

Similar Threads

  1. Replies: 2
    Last Post: 10-11-2009, 01:31 PM
  2. Object Version Management with a Database
    By MiniMik in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 08-21-2009, 10:05 AM
  3. How to Load Java Object into Oracle Database
    By dorairaj in forum Advanced Java
    Replies: 3
    Last Post: 01-12-2009, 03:37 PM
  4. How to insert java Object in oracle database
    By Thilkumar82 in forum Advanced Java
    Replies: 9
    Last Post: 08-13-2008, 12:33 PM
  5. SPT Object Database 0.2.0
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-23-2008, 03:03 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts