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 |
Difference between static methods, static variables, and static classes in Java.
I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file.
What is interface and its use?
What is the difference between multitasking and multithreading in Java
0 Answers Sans Pareil IT Services,
Can you extend main method in java?
what is difference between String buffer and String builder?
What are the high-level thread states in java programming?
How many bits is a string in java?
class{ ... ... interface myinterface{ ... ... } abstract class{ .. .. } ... .. .. } is this possible to write "Interface and/ or Abstract class inside a class ? if possible whcich one is possible is only interface? is only abstract?
What is hashset in java?
What is concurrent hashmap and its features?
What are the data types supported by java? What is autoboxing and unboxing?