Home Answers Viewqa JDBC Store ResultSt Data in a Map

 
 


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

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

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 Pages:
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
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
store
store  i want to store data in (.dat) file format using swing and perform operation on that insertion,deletion and update
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
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
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
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
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
Stoting file name in Map
Stoting file name in Map  how to store id and file name in map
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
Batchwise Store
Batchwise Store  i want to read the column from excel and store the data as batchwise into database
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
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
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
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
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
java run time textfield and use with map - Java Beginners
read data from file and store in map and display in different textfields which are generated at run time like a text file store information class a1...) throws Exception { JButton b=new JButton("Put file data into TextFields
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. 
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
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
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
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
Map
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image
Java Map Iterate
Map is an Interface in the Collection Framework. Map is implemented by its two sub classes HashMap Treemap Map has no iterator method. So use the entrySet() method.It returns the data as Set Example of Java Map
dbase store - JSP-Servlet
dbase store  HI! In my project i have to store phone number in dbase. i used numeric (11,0) as data type for phone number. When i am trying to store the phone number, It is show showing error for Input String "given phone number
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
Java Map iterator with example
Java Map Iterator is an interface. It keeps the data in the key and value form. It is implemented by HashMap, Tree Map. Map has no iterator method. So...() method to get the data in Set object form. Java Map Iterator with Example
About Store Procedure
About Store Procedure  Create Procedure CMTSPCasesByWorkstream..._data Print 'Table Dropped' END [DECLARE @paramdateincrement int = 24... in brackets its working for one day only ,if i open on another day the data
Wiring Map Collections
Wiring map collections The <map> element is used to store values in key...; defines a member of the Map. Lets take an example to demonstrate how map... and authorsInfo is of Map type. import java.util.*; public class Article
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
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 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>
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
iterate through map and write the content in a separate file
iterate through map and write the content in a separate file  I am trying to save the data from file to a map, then iterate through map and write it to a separate file.My data looks like this: Concept:Conferences:conferences
iterate through map and write the content in a separate file
iterate through map and write the content in a separate file  I am trying to save the data from file to a map, then iterate through map and write it to a separate file.My data looks like this: Concept:Conferences:conferences
iterate through map and write the content in a separate file
iterate through map and write the content in a separate file  I am trying to save the data from file to a map, then iterate through map and write it to a separate file.My data looks like this: Concept:Conferences:conferences

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.