This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Retrieving info from Office Microsoft Access

Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code is from core servlets and JavaServer Pages(2nd Edition) by Marty Hall. i want to know how i can change the code below to list the items available in inventory from a database(Microsoft Office Access)(table name is tbltemDetail).As the code after the new Item is place there using a static table.Actually i want to use a array to store the info from the ResultSet.

private static Item[] items =
{ new Item("hall002",
"<I>Core Web Programming, Java2 Edition</I> " +
"by Marty Hall, Larry Brown, and " +
"Paul McNamee",
"One stop shopping for the Web programmer. " +
"Topics include \n" +
"<UL><LI>Thorough coverage of Java 2; " +
"including Threads, Networking, Swing, \n" +
"Java2D, and Collections\n" +
"<LI>A fast introduction to HTML 4.01, " +
"including frames, style sheets, layers,\n" +
"and Netscape and Internet Explorer " +
"extensions.\n" +
"<LI>A fast introduction to HTTP 1.1, " +
"servlets, and JavaServer Pages.\n" +
"<LI>A quick overview of JavaScript 1.2\n" +
new Item("lewis001",
"<I>The Chronicles of Narnia</I> by C.S. Lewis",
"The classic children's adventure pitting " +
"Aslan the Great Lion and his followers\n" +
"against the White Witch and the forces " +
"of evil. Dragons, magicians, quests, \n" +
"and talking animals wound around a deep " +
"spiritual allegory. Series includes\n" +
"<I>The Magician's Nephew</I>,\n" +
"<I>The Lion, the Witch and the " +
"Wardrobe</I>,\n" +
"<I>The Horse and His Boy</I>,\n" +
"<I>Prince Caspian</I>,\n" +
"<I>The Voyage of the Dawn " +
"Treader</I>,\n" +
"<I>The Silver Chair</I>, and \n" +
"<I>The Last Battle</I>.",
new Item("alexander001",
"<I>The Prydain Series</I> by Lloyd Alexander",
"Humble pig-keeper Taran joins mighty " +
"Lord Gwydion in his battle against\n" +
"Arawn the Lord of Annuvin. Joined by " +
"his loyal friends the beautiful princess\n" +
"Eilonwy, wannabe bard Fflewddur Fflam," +
"and furry half-man Gurgi, Taran discovers " +
"courage, nobility, and other values along\n" +
"the way. Series includes\n" +
"<I>The Book of Three</I>,\n" +
"<I>The Black Cauldron</I>,\n" +
"<I>The Castle of Llyr</I>,\n" +
"<I>Taran Wanderer</I>, and\n" +
"<I>The High King</I>.",
new Item("rowling001",
"<I>The Harry Potter Trilogy</I> by " +
"J.K. Rowling",
"The first three of the popular stories " +
"about wizard-in-training Harry Potter\n" +
"topped both the adult and children's " +
"best-seller lists. Series includes\n" +
"<I>Harry Potter and the " +
"Sorcerer's Stone</I>,\n" +
"<I>Harry Potter and the " +
"Chamber of Secrets</I>, and\n" +
"<I>Harry Potter and the " +
"Prisoner of Azkaban</I>.",

public static Item getItem(String itemID) {
Item item;
if (itemID == null) {
for(int i=0; i<items.length; i++) {
item = items[i];
if (itemID.equals(item.getItemID())) {
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would need a database. I'll move this to the [b]JDBC[/i] forum for you.
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its better to use VO/TO, Value Object/Transfer Object, to store the resultset values and place them into any suitable collection object.

You can iterate over that collection to render those items into your html table.

Best is to use JSP for presentation, instead of doing it all in a servlet.
Nico Yukiko
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As i have created a lots of classes of related i hope that this can be done in servlet. Can anyone provide the code for me of how to retrieve the static table of the given codes. as i already have a table of the item i wish to place into the interface.

How i can use an array to retrieve information from a resultSet. and loop through to replace the new CatalogItem{"lewis001","description"} instead of placing the static codes
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic