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 use of functional interface in java 8?
Can java object be locked down for exclusive use by a given thread?
What are the two types of java?
What is the exact difference in between Unicast and Multicast object? Where will it be used?
Why java is secure? Explain.
What does n mean?
when a request is generated from apache tomcat 5.5 and goes to oracle 10g or mysql,,, how the oracle or mysql reads the request as apache is a web server and oracle 10g is application server? when the oracle 10g provides response, how the apche tomcat reads it???
Is singleton class immutable?
What do you mean by global variable?
Can a class have multiple subclasses?
What are the types of collections in java?
Is it possible for a yielded thread to get chance for its execution again?
What is size () in java?
How to declare objects of a class ?
What is the symbol for space?