Comment on Tutorial - HashMap example in Java By Charles



Comment Added by : A Sadist

Comment Added at : 2012-07-05 12:13:45

Comment on Tutorial : HashMap example in Java By Charles
answers to the questions asked by ranjan in comment #24

yes ranjan it is very task if u has small knowledge on jdbc,
i will write the code(only logic) regarding to ur question:

step1:load driver
step2:create connection
step3:create statement
step3:execute quire and store the result in ResultSet


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:FTW", "ur_name", "ur_lover_name");
//generally usernames are their names and passwords are their lover names//Step1
String st1="select uname, pass from Emp";
Statement st = con.createStatement();
ResultSet rs=st.executeQuery(st1);
Map m1 = new HashMap();
String my_name,my_lover_name;
while(rs.next())
{
my_name = rs.getString(1);//i.e user name
my_lover_name = rs.getString(2);//i.e passward
m1.put(my_name , my_lover_name); //here we add to our map

}
see how romantic this java is just enjoy


View Tutorial



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. i want some more info to make my final project.
View Tutorial          By: Arshid saeed at 2010-02-18 08:18:45

2. i have created a listview and i have a button in t
View Tutorial          By: prateek at 2013-05-19 18:52:47

3. Thank you
View Tutorial          By: Angeline at 2011-06-28 06:27:12

4. mail goes as a single line statement, how to prese
View Tutorial          By: kishor at 2011-06-23 13:35:21

5. It is very Important Site
View Tutorial          By: Shridhar Koli at 2011-12-29 11:43:29

6. I want to using swith with string...
How to

View Tutorial          By: anuj at 2015-03-04 18:22:29

7. Wow! Thank you!
View Tutorial          By: David at 2013-04-24 15:52:45

8. This code worked but it only add the same vales se
View Tutorial          By: Dammy Temmy at 2013-01-17 17:22:17

9. PLZ HELP ME WITH THIS.. WHEN I RUN THE FILE ON APA
View Tutorial          By: Rahul at 2012-08-18 12:26:39

10. Its informative and helpful. Thanx
View Tutorial          By: Usama at 2012-07-14 22:16:45