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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is Marker interface?

1034


How many inner classes can a class have?

993


Is there any case when finally will not be executed?

900


How do you declare an array in java?

983


Which data type is a class in java?

934


When is update method called?

1090


What modifiers may be used with a top-level class?

999


what is the difference between future and callable interface in java?

1146


what is a thread pool in java and why is it used?

936


What are streams in java 8?

945


extending thread class or implementing runnable interface. Which is better? : Java thread

955


How do you create a bulleted list?

1195


What is hash table in java?

940


What are the drawbacks of reflection?

957


Where are global variables stored?

889