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. this is WRONG!

your IF should be:
View Tutorial          By: notnooblikeyou at 2013-01-29 15:11:30

2. its work well , thanks for code , but if any body
View Tutorial          By: mary at 2007-12-16 07:10:58

3. for me also The code gives the following exception
View Tutorial          By: Nilesh Agrawal at 2012-06-06 15:55:02

4. Its not working ave made a few adjustments to it t
View Tutorial          By: amg at 2011-11-04 13:48:09

5. Thanks for the clear explanation..
Really h

View Tutorial          By: Swj at 2011-12-30 05:55:26

6. i have to learn java
View Tutorial          By: md arif alam at 2013-04-15 18:30:27

7. Hi, i tried this tutorial with my own database and
View Tutorial          By: Dejan at 2015-03-18 13:06:27

8. I have loaded allthe 5 java files.But how to imple
View Tutorial          By: devi at 2008-04-01 01:02:28

9. good one
View Tutorial          By: yogesh at 2010-07-24 21:18:24

10. Hi thanks for the example for overriding toString(
View Tutorial          By: Reshma at 2011-05-11 10:46:08