Retrieving database values and put in Hashmap

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smartpriya
    New Member
    • Feb 2008
    • 3

    Retrieving database values and put in Hashmap

    Hello,
    I am doing project in Swing and Access. I have some Tables in database.. Now I need to retrive some values from it and put in Hashmap.

    For ex: I have 3 tables like Node, Card, Line.
    Node table contains Node name, Node id, etc..
    Card table contains Node id, Card Type..
    Line table contains Node id, Line Type..

    Now i want values from fields Node name,Card Type, Line Type and to be put in Hashmap..so that based on these values, I have to construct an JTree..

    Could anybody plz say what is the respective code to retrieve from database
    and put it in Hashmap..

    Thanks in advance,
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Insufficient data for meaningful response.

    I don't understand your domain model or why you need a Map.

    If you don't know how to interact with a database in Java, you need to take the JDBC tutorial: http://java.sun.com/docs/books/tutorial/jdbc/index.html

    Comment

    • Smartpriya
      New Member
      • Feb 2008
      • 3

      #3
      Hello,

      Now , i make it clear about my project. I am working in Swing and i am using the backend as MS-Access..I want to construct the JTree.like this...

      Node1
      +
      ++Slot1
      + ++line1
      + ++line2
      + ++.......
      ++Slot2
      + ++line1
      + ++line2
      + ++-......
      +Node2
      +
      ++Slot1
      + ++line1
      + ++line2
      +.............. ..

      Right! This is I have to construct.... If i click the Node, the Node details in the database should be displayed....(N ode id, Node name..)

      Similarly for slot and line also, it should be displayed in the right pane...

      It works fine when i construct the JTree.

      But, my team leader asks me to retrieve the database values and put it in Hashmap... and from Hashmap, i have to construct the JTree.

      I can construct the tree without Hashmap, but when I add new details in the database, it is not displayed in JTree..

      But if i put in Hashmap and then construct the tree, it will display the newly added details.. Isn't it?

      I think, you got my idea...

      I know very well about those details(select * from tablename ) etc..... and about Hashmap also ..that is not my problem.

      Now my problem is , how to retrieve values from database and put in Hashmap..

      Will u give 1 small example plz...?

      Am i now clear?

      Thanks for your patience..

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Thanks, that's much clearer. The way these forums works however is that posters don't supply sample code so readily. Rather, posters ask specific questions about code they post and then other forum members post their suggestions.

        Comment

        • Smartpriya
          New Member
          • Feb 2008
          • 3

          #5
          Will u dont provide code?It's ok..
          But will u suggest, Which book or link will be helpful for me to do my project? Because I searched in google a lot .. But still i didn't get any idea..

          If no problem for you, plz give some idea...

          Thank you.....

          Comment

          • BigDaddyLH
            Recognized Expert Top Contributor
            • Dec 2007
            • 1216

            #6
            Originally posted by Smartpriya
            Will u dont provide code?It's ok..
            But will u suggest, Which book or link will be helpful for me to do my project? Because I searched in google a lot .. But still i didn't get any idea..

            If no problem for you, plz give some idea...

            Thank you.....
            There are two basic halves to your problem, which should be understood and solved separately:
            * Java working with a database
            * A Swing GUI

            How much do you know about each topic?

            Here are two tutorials, one on each subject:
            This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions

            This Swing Java Tutorial describes developing graphical user interfaces (GUIs) for applications and applets using Swing components

            Comment

            Working...