how can you retrive information from database by using
hashmap/arraylist ,plz explain with example briefly?



how can you retrive information from database by using hashmap/arraylist ,plz explain with example..

Answer / none

import java.util.*;
import java.sql.*;

public class Jdbc
{
public static void main(String[] a)
{
Connection conn=null;
try
{
String s1="Driver name for registration";
Class.forname(s1);
String url="Driver Port No name";
String username="Database Username";
String password="Database password";

conn=Drivermanager.getConnection(url,username,password);
String sql="SELECT name,address FROM tb"
Statement stmt=conn.createStatement(sql);
Resultset rs=stmt.executeQuery();

ArrayList al=new List();
while(rs.hasnext())
{
al.add(index,rs.getString());
}
rs.close();
stmt.close();
conn.close();
}
//handle Exceptions
}
}

Is This Answer Correct ?    8 Yes 4 No

Post New Answer

More Core Java Interview Questions

What happens when I use / and % with a negative numerator?

1 Answers  


What is parsing a sentence?

1 Answers  


How many characters is 2 bytes?

1 Answers  


Is list ordered in java?

1 Answers  


What is structure of java heap? What is perm gen space in heap?

1 Answers  


What is ascii format?

1 Answers  


What is string literal in java?

1 Answers  


What if I write static public void instead of public static void in java?

1 Answers   Winsol Solutions,


What is void in java?

1 Answers  


What are dot operator queries?

1 Answers   Atos Origin,


Name the methods in mouse listeners ?

4 Answers  


How do you create a bulleted list?

1 Answers  


Categories