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



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 complete notes on java from basics
View Tutorial          By: spandana at 2010-02-12 04:44:13

2. Hi,
I'm studying core java.java is new for

View Tutorial          By: shantkumar at 2011-12-01 17:02:26

3. Best Example for Inheritance. Thank lot!

View Tutorial          By: Periyasamy C Chennai at 2010-07-09 01:35:30

4. i get exception NoSuchPortException. i tried on di
View Tutorial          By: harryjoy at 2009-11-22 05:52:48

5. hi....
i want to send sms to any mobile by

View Tutorial          By: prerna at 2010-07-09 20:15:48

6. Thanks
muchas gracias
Excellent

View Tutorial          By: Alfredo at 2010-05-31 09:00:36

7. To 25
void *memset( void *buffer, int ch, s

View Tutorial          By: Doniv at 2011-12-15 10:10:52

8. Hi,
What should be done to correct the erro

View Tutorial          By: Raymond at 2011-03-07 08:51:54

9. i m student ,can any one help me in above code str
View Tutorial          By: devendra kumar at 2010-03-09 04:34:10

10. u doing good
View Tutorial          By: matsiko at 2009-04-14 08:05:00