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. thanks for posting
View Tutorial          By: sriram at 2011-11-24 06:38:42

2. how to use isset keyword with multidimensional arr
View Tutorial          By: mehul at 2015-01-19 23:47:02

3. plz send me some interview based simple java progr
View Tutorial          By: Abilesh at 2013-06-23 06:43:03

4. sir i want this following pattern using loops

View Tutorial          By: teju at 2015-09-13 22:46:58

5. If you use comments you will have better idea abou
View Tutorial          By: Mohammed Homam at 2009-12-06 04:43:51

6. excellent...... thank you so much.
View Tutorial          By: balaji at 2011-07-19 07:56:08

7. THANKS!!!
Just the essential, core things-t

View Tutorial          By: Galaxio at 2010-12-29 04:25:33

8. it works well thanks
View Tutorial          By: Zahran at 2011-12-08 03:07:07

9. very very useful..thank you
View Tutorial          By: sridaran at 2009-03-21 00:45:21

10. thanks man really very nice and helpful...........
View Tutorial          By: Bakhtawar khan at 2012-12-05 05:54:18