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. Can you Please send me the code for movable clock
View Tutorial          By: Rajagopal at 2008-09-29 23:10:57

2. Don't you just love people who all assume we use w
View Tutorial          By: Alan at 2012-08-01 09:10:26

3. site is good.explaining the concept with nice pro
View Tutorial          By: AJOY KUMAR MANDAL at 2012-11-22 01:57:26

4. thanks....good explanation...
View Tutorial          By: jiby at 2012-01-14 05:57:33

5. To handle multiple submit buttons you can use stan
View Tutorial          By: Vic at 2008-12-23 12:03:43

6. This is great, hope to learn more from this commun
View Tutorial          By: Wamaguru at 2014-07-12 09:05:30

7. Tnx. Very fast learning i think.
Just make

View Tutorial          By: mahdi at 2011-07-09 20:20:39

8. Hi people,
for those getting the Time out

View Tutorial          By: Ramlak at 2008-05-08 08:28:29

9. Following line
if (strcmp(dp->

View Tutorial          By: Sebastiaan Jaarsma at 2012-12-24 19:28:43

10. I have some questions : 1) Which type of GC used
View Tutorial          By: SP at 2013-06-04 15:48:59