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 |
Why does java have two ways to create child threads? Which way is better?
What is private public protected in java?
What are void pointers?
which one is performance wise advantageious from List,Set,Map?
What does system.gc() and runtime.gc() methods do?
Describe the term diamond problem.
What is meant by class loader? How many types are there?
Java support what type of parameter passing ?
What are the restrictions that are applied to the java static methods?
Is java a prime method?
Explain numeric promotion?
What is an eror in java?