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. Hi ..

I'm try to run the full samp

View Tutorial          By: Eng.A at 2009-02-21 03:11:02

2. vinod kumar for j2me app development we need one I
View Tutorial          By: saurabh dixit at 2013-04-18 09:59:23

3. hi issac thank you for your sample. can you please
View Tutorial          By: edwin at 2009-05-20 22:04:14

4. Do the serialized output is displayed in the file
View Tutorial          By: Atihs at 2012-11-17 02:38:52

5. know someone how to compare various objects?

View Tutorial          By: Peter at 2009-10-07 07:32:31

6. This code worked but it only add the same vales se
View Tutorial          By: Dammy Temmy at 2013-01-17 17:22:17

7. please tell me.........
View Tutorial          By: case c++ at 2012-02-20 02:45:55

8. i have same error sir..
Error applying tran

View Tutorial          By: CRUDZ at 2013-10-13 05:22:24

9. Thanks for your nice article.I learned a lot
View Tutorial          By: Mahyar at 2012-08-12 12:09:36

10. Thank you! :) But I have a question, why is that t
View Tutorial          By: choco at 2010-01-03 02:16:18