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. Hello,

I've got javax.comm and fol

View Tutorial          By: Ashkan at 2009-12-19 21:51:19

2. the exampe was really useful........
View Tutorial          By: smitha at 2011-03-10 21:27:55

3. good tutorial for beginners..........
View Tutorial          By: Madarapu naveen at 2011-06-18 11:19:50

4. pl tel me how to open port no

i can

View Tutorial          By: SUdhir at 2011-01-28 00:21:55

5. can anyone tell me which type of device i need to
View Tutorial          By: dhanunjay at 2009-04-01 00:31:17

6. I wont to know about every thing of java
View Tutorial          By: susantha at 2009-10-11 09:35:40

7. Finally a tutorial that clearly explains why Hasht
View Tutorial          By: Lisa Ander at 2011-10-27 20:33:15

8. So simple..Very easy to understand
View Tutorial          By: G.Tejasree at 2011-11-05 11:51:38

9. thnx for the nice tutorial. but i need to create a
View Tutorial          By: sharath at 2013-09-07 16:29:19

10. hi,
plz help me i cannot find the way out o

View Tutorial          By: Yash at 2008-05-07 16:59:20