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



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 like this tutorial, it is self explaining. good
View Tutorial          By: Nikia at 2013-01-25 20:04:30

2. GC.Collect is for .net not for java don't get conf
View Tutorial          By: asin at 2013-06-27 15:47:35

3. Thanks alot. Really great and simple example!
View Tutorial          By: leo at 2011-06-06 13:58:32

4. an excellentttttttt siteee
View Tutorial          By: raza at 2011-04-02 10:39:46

5. can i using stack in microsoft access 2007
View Tutorial          By: pxin at 2015-03-24 05:45:56

6. i'm a student and new to all these HTML and JSP.
View Tutorial          By: sillee at 2009-08-13 03:22:14

7. I am developing a system for paying electric bill
View Tutorial          By: Isaya at 2007-03-26 01:11:59

8. Timely info right when I needed it. Thanks.
View Tutorial          By: Electric Vehicles at 2008-12-10 15:15:25

9. Hii,,,i have a java server socket program and i wa
View Tutorial          By: prawinmasthan at 2012-01-13 08:38:35

10. Awesome .
Helpfull!!

View Tutorial          By: ARMLAB-NG at 2009-06-06 09:22:00