how can you retrive information from database by using
hashmap/arraylist ,plz explain with example briefly?
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 |
What is final variable?
How are the elements of a gridbaglayout organized?
what is heap memory?
0 Answers Tavant Technologies, Zensar,
What is flush () in java?
Why generics are used in java?
Which Java operator is right associative?
What is the difference between compile-time polymorphism and runtime polymorphism?
What is super?
Difference between String & StringBuffer
16 Answers IBM, Infosys, Tech Mahindra, Wipro,
How many functional interfaces does java 8 have?
when should you use stringbuilder class in a program?
What is thread pool? How can we create thread pool in java?