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 is the purpose of object oriented programming?

0 Answers  


whats string ?

10 Answers   HCL,


how does multithreading take place on a computer with a single cpu? : Java thread

0 Answers  


What is methods and methodology?

0 Answers  


What is the static keyword?

0 Answers  






Should you use singleton pattern?

0 Answers  


Hi friends i want display Triangle shap stars(*) please can tell me any one java code logic? * *** ***** ******* Like this

2 Answers   NIIT, TCS,


Can an abstract class be a final class?

0 Answers  


List down the methods and interfaces of collection class in java.

0 Answers  


An inner class can actually be a subclass of the outer class? a. true b. false

2 Answers  


What is object class in java?

0 Answers  


What are the 4 types of characters?

0 Answers  


Categories