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. Thanks...it was very helpful :)
View Tutorial          By: Swathi at 2012-01-25 06:49:46

2. Thank you, this tutorial is well-written and made
View Tutorial          By: Adrien T├ętar at 2012-10-28 19:01:57

3. @Askia-Just change RadioButton1 to RadioButton2 in
View Tutorial          By: Nelson at 2010-03-06 23:12:36

4. I got error during using above code if There is ne
View Tutorial          By: Sunil at 2009-12-28 05:22:45

5. Please resolve this problems :

ja

View Tutorial          By: madhusudhakar at 2014-10-24 06:11:10

6. When i run the program,Iam getting this

View Tutorial          By: anitha at 2008-12-17 21:37:36

7. I want simple programs using BuffuredReader for m
View Tutorial          By: Why ask my name? at 2013-06-01 04:56:00

8. it doesn't count for the values like 001 or 02 et
View Tutorial          By: angesh at 2012-02-10 16:15:02

9. hi,im working with a project,in which i have to se
View Tutorial          By: gomathi at 2008-12-08 09:04:35

10. hi ,
i am a beginner in java. please tell m

View Tutorial          By: aun at 2011-11-18 06:47:56