Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Store ResultSt Data in a Map

Have Programming Question? Ask it here!
 
 
 


Timir kumar jena
Store ResultSt Data in a Map
1 Answer(s)      2 years and 11 months ago
Posted in : JDBC


i want to store data in a hash Map .Please solve my problem as soon as possible.


Advertisement
View Answers

September 13, 2011 at 11:03 AM


import java.sql.*;
import java.util.*;

public class MapExample {
    public static void main(String[] args) {
    Map<String,String> map = new HashMap<String,String>();
      try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
      Statement st = con.createStatement();
      ResultSet rs = st.executeQuery("SELECT * FROM  data");
      while(rs.next()){
        map.put(rs.getString("id"),rs.getString("name"));
      }
       System.out.print(map);
      }
      catch(Exception e{
        System.out.print(e);
      }
    }

}


Related Tutorials/Questions & Answers:
Store ResultSt Data in a Map
Store ResultSt Data in a Map  i want to store data in a hash Map .Please solve my problem as soon as possible
How to hold data in map
How to hold data in map  Holding data in map: i have user1 and he has account1,account2,accoutn3 like that user2,user3 will have accounts. now how to hold users and their accounts in hashmap
Advertisements
read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
Java Xml Data Store
be followed up and/or purchased. You will need to store the data in a local binary... the implementation needs to change later on (perhaps they might decide to store the data...Java Xml Data Store  I have to do this project and i'm finding it so
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
to store data entered in html page
to store data entered in html page  i want to a job site... submit we have to move to form 2 on there we have enter text data in the textfield after that by clicking submit button data enter in form 1 and 2 should
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable in order to apply some calculation on it, but now i want to store the result
project in JSP and XML(to store data)
project in JSP and XML(to store data)  I need to complete an assignment in JSP and using XML as Database ,Please help me to complete this assignment.Ill be very very thankful to you,i am new to JSP.Please provide full code
for store data in data base - JSP-Servlet
for store data in data base  i want to a job site, in this site user can registered by a form.. in this form there are his information... i use..... and on 3rd form i use submit button... data of form 1 and 2 can also be store
Use Map to display file data into textfields
Use Map to display file data into textfields Collection framework allows a programmer to store,retrieve, manipulate, and communicate aggregate data easily. You have mostly used ArrayList or Vector classes to store the file data
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having emp id, projectname and emp name.I want to store data related to employee in xml file.How can i store data entered by user in XML file and later retrieve data
map
map  using map, i want display message based on id selected [both are strings]   i do no   Hi Friend, Try the following code...) { Map map=new HashMap(); map.put("Message1","Hello
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
Map
Map  If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map either iterator or for each loop or for loop
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir , I am working on a project , in which I have to apply operation on input data... to store that data in int variable. how to do this ?   Here is an example
data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm=con.createStatement(); String query="select * from employee where ename=\'"+ename+"\'"; ResultSet rs=stm.executeQuery(query
how to get data from list to map with out using a loop?
how to get data from list to map with out using a loop?  List list...("15"); how to get this data into map with out using a loop. i want this data like this--map.put(name,id); Is it possible to do without using loop
how to store data in a text file - Java Beginners
how to store data in a text file  Hi friends, I want to know, how we can save the data in a .txt file using swings....... for example, i want to store the arraylist data of swing program into a text file.......and also i want
store
store  i want to store data in (.dat) file format using swing and perform operation on that insertion,deletion and update
how to store data in other table using servlet and jsp
how to store data in other table using servlet and jsp  pls can anyone tell how to store data in other table using servlet and jsp and want to display that data too.and the data in first table must be same.pls help
How to read excel data and store it in database - Java Beginners
How to read excel data and store it in database  Hi, I want a java code to read data from excel and store it in Ms Access database.I tried the code but but its printing the output in console.I dont know how to store the excel
How to passed the ID's in MAP how to stored whaterver select the name that only ID should store in db using SWING/AWT?
the ID's in MAP how to stored whaterver select the name that ID should store...How to passed the ID's in MAP how to stored whaterver select the name that only ID should store in db using SWING/AWT?  Hi, I am working on SWING
how to store JTree data hierarchically in mysql database from netbeans
how to store JTree data hierarchically in mysql database from netbeans  how to store JTree data hierarchically in mysql database from netbeans. I am new to this topics so I need a program and tables you are using in database
store
store  hi i want store some information in my program and use them in other method. what shoud i do
how to store the data in a array retrived from the database - JSP-Servlet
how to store the data in a array retrived from the database  hi Friends,actualy my requriement is i need to disply the complete working time...: http://www.roseindia.net/jdbc/display-data-database.shtml Even though
how to store data in table using swings - Java Beginners
how to store data in table using swings  Hi, I am doing a project in which i need to store some data in the table using swings.......Iam using... will be same to store data into tables) of my application....can any body give an example
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval..., projectname and emp name.I want to store data related to employee in xml file.How can i store data entered by user in XML file and later retrieve data
How to store data entered by User in JSP page in XML file
How to store data entered by User in JSP page in XML file  How to store data entered by user in JSP page to be saved in XML file.On clicking submit...   JSP store data entered by user into XML file 1)form.jsp: <html>
Map interface
Map interface  What is the Map interface
Stoting file name in Map
Stoting file name in Map  how to store id and file name in map
arraylist not able to store large amount of data( over 1 lakh records) - Java Interview Questions
arraylist not able to store large amount of data( over 1 lakh records)  A result set containing over 1 lakhs of records is used to set data... function that iterator is used to iterate and data from above arraylist is used
Hash Map
Hash Map  how to add the hash map objects in the list and iterate the objects
Interactive map
Interactive map  hi........ i require map to be zoom in and enlarge the area and show its detail. Can anyone tel me how can this be done using java swings .... plz help
Map code
Map code  hi................ I have map of navi mumbai, where i want to see the location vashi, nerul, turbhe.... means want to zoom into this area and then again zoom in and see nerul location more properly or other location
Map
hash map
hash map  write a program in hash map , that shows the value in asending order. but not key value. ex: key value ==== ===== k5 ashutosh k1 babita k7 debasis k2 vikas plz help me
Google Map Integration - Ajax
Google Map Integration  Hi All, I am working on a vehicle tracking system project. I have to read data from sql server database and map the vehicle position in google map. I need to use ajax as the data is updated in every
Batchwise Store
Batchwise Store  i want to read the column from excel and store the data as batchwise into database
hash map
=2; HashMap<Integer,Test> map=new HashMap<Integer,Test>
J2me Map load error
J2me Map load error  Hi , i am making a POC to load google map in my mobile,now i m getting the address of location by its lattitude and longitude in web page , but thing is i wana to store in my net beans emulator , its showing
Data Provider
Data Provider       Flex provides some objects that store data that can be used by other components. For example, arrays and collections contain data so they are known as data providers
Reading Text file and storing in map
Reading Text file and storing in map  Hi I have multiple text files. I want to read thoses files and store those records in map. Map will be of "LinkedHashMap<String, Map<String, String>>" type. Please let me know
Introduction to Map and SortedMap Interface
first data: Sunday Now the tree map Keys: [1, 2, 3, 4, 5, 6] Now... Introduction to Map and SortedMap Interface       Map Interface: A Map
J2ME Record Data Base
J2ME Record Data Base       This Application is used to explain how to store data in the database... the RecordStore class. The RecordStore class is used to get the data through
Java Map
Java Map         In Java, a Map is a kind of generalized array. It provides a more general way of storing elements. It is an object that maps keys to values. Map
 

 

 

DMCA.com