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

write a program to create an vector and listeterator.and value should be enter through keyboard.

1 Answers   Axcend,


What is the biggest integer?

0 Answers  


How do you convert string to int in java?

0 Answers  


what is thread? What are the high-level thread states? : Java thread

0 Answers  


What is float in java?

0 Answers  


what is main purpose of interface?

2 Answers   Accenture, HCL, NIIT,


Which class should you use to obtain design information about an object in java programming?

0 Answers  


What is private static class in java?

0 Answers  


Realized?

0 Answers  


What is scanner in java?

0 Answers  


How do you start a new line in java?

0 Answers  


is it mandatory to deaclare all variables public static fianl in interfaces?if i declare like in the below program, public interface A { public static final int I=0; int j=0; } in interface A,what is the difference between I,j?

2 Answers  


Categories