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 for the example taken directly from the Jav
View Tutorial          By: Lewis Chase at 2013-09-24 23:39:21

2. can you plase give an exmple of what should i put
View Tutorial          By: Or at 2013-02-16 11:32:17

3. class Evaluate
{
public static void

View Tutorial          By: prajjawal at 2013-02-27 12:36:58

4. thanx very much...
View Tutorial          By: Rajesh at 2015-10-09 08:57:36

5. a very rare but useful tutorial. Thanks a bunch!
View Tutorial          By: Dalitso at 2014-02-19 12:07:34

6. you're so great!
View Tutorial          By: renz at 2008-08-10 18:29:59

7. how to connect the database in servelet use to sta
View Tutorial          By: sudhir singh tomar at 2011-04-28 03:10:34

8. hi..!!
In the above code samples there is a

View Tutorial          By: chiru at 2009-07-03 03:29:18

9. Yes, finaly toString start making sense to me, tha
View Tutorial          By: Ted at 2010-04-10 19:15:50

10. when i copy paste your program or source code

View Tutorial          By: Zordan at 2011-03-17 04:28:08