• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can we use Map for accessing data from database.

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all,
I want to access database using map. My database is in Oracle 10g.
can we access.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NO, you can't access database using Map, you need JDBC.
And if you want to store database row data into the Map, then you have to do something like this:

Please note, I haven't initialize the object.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And this shouldn't be asked in Servlet section, its related to JDBC and MUST be asked in JDBC section.
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:And this shouldn't be asked in Servlet section, its related to JDBC and MUST be asked in JDBC section.



Pl. tell me, how should i transfer my query to JDBC section..
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already done.
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:NO, you can't access database using Map, you need JDBC.
And if you want to store database row data into the Map, then you have to do something like this:

Please note, I haven't initialize the object.






Hi..
I am using map for retrieving database contents..
Now i am able to save my contents in map, but i am not getting how to get it back
for displaying purpose / for further processing

My code is like this

Now here after i want to retrieve the data which i saved in this map.
how should i do this?
please tell me...
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sample code from my project ^

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rupa Katkar wrote:Now here after i want to retrieve the data which i saved in this map.


Where do you want to display this data, Don't make us guessing !

Still, I guess its JSP :
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jonathon Stride wrote:sample code from my project ^




Actually the database with which i am dealing is very large.
so i think to retrieve its contents Map is suitable..
& here in Jonathon's code i am able to access only BATCH_NO from table.
remaining fields i am unable to access..
How should i access to fields.
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

Rupa Katkar wrote:Now here after i want to retrieve the data which i saved in this map.


Where do you want to display this data, Don't make us guessing !

Still, I guess its JSP :




Hi Sagar,

I want to retrieve the table contents first, then i am going to process on that data.
& after processing the results i have display on jsp page.
But first i should able to retrieve the whole data from my database. my table contains thousands of records.
Please you suggest me should i go for Map or should i use something else.

Finally after processing data i am going to display it on jsp page only.

thanks for your support.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, I correct your original code:

Rupa Katkar wrote:& here in Jonathon's code i am able to access only BATCH_NO from table.
remaining fields i am unable to access..
How should i access to fields.



To access both the key and value:


But first i should able to retrieve the whole data from my database. my table contains thousands of records.
Please you suggest me should i go for Map or should i use something else.


Its depends upon, what you want to do with the data. Map's are used to associate the bunch of data with the unique identifier.
 
Rupa Katkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:First, I correct your original code:

Rupa Katkar wrote:& here in Jonathon's code i am able to access only BATCH_NO from table.
remaining fields i am unable to access..
How should i access to fields.



To access both the key and value:


But first i should able to retrieve the whole data from my database. my table contains thousands of records.
Please you suggest me should i go for Map or should i use something else.


Its depends upon, what you want to do with the data. Map's are used to associate the bunch of data with the unique identifier.



Sagar, your code is working in my project, thanks for that..
One thing i want to ask is



in this code, we are not using this "b" object anywhere, how should we use it..
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rupa Katkar wrote:
in this code, we are not using this "b" object anywhere, how should we use it..


I think you want to use "bean", that's why I kept that code as it is. But if your need is fulfilled without using the bean instance "b", then you can delete that line.
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic