Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 final variable?

0 Answers  


How are the elements of a gridbaglayout organized?

0 Answers  


what is heap memory?

0 Answers   Tavant Technologies, Zensar,


What is flush () in java?

0 Answers  


Why generics are used in java?

0 Answers  


Which Java operator is right associative?

3 Answers  


What is the difference between compile-time polymorphism and runtime polymorphism?

0 Answers  


What is super?

0 Answers  


Difference between String & StringBuffer

16 Answers   IBM, Infosys, Tech Mahindra, Wipro,


How many functional interfaces does java 8 have?

0 Answers  


when should you use stringbuilder class in a program?

0 Answers  


What is thread pool? How can we create thread pool in java?

0 Answers  


Categories