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
What is the purpose of tostring() method in java?
Where are the card layouts used?
Explain about static nested classes in java?
Which is best ide for java?
When super keyword is used?
Explain polymorphism citing an example.
Implementations of set interface?
Can an integer be null java?
How do you create a first line indent?
What is the size of string?
What does opcode mean?
What is procedure overloading?
Which of the classes will have more memory allocated?
What are sets in java?
Can we declare array without size in java?