Académique Documents
Professionnel Documents
Culture Documents
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* @author murali
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class DBConnection {
if(c==null)
connect();
return c.createStatement().executeUpdate(url);
}
public static ResultSet Query(String url)throws Exception{
if(c==null)
connect();
return c.createStatement().executeQuery(url);
/**
* @param stmt
* @param rs
* @param connection
*/
public static void close(Statement stmt, ResultSet rs, Connection connection) {
// TODO Auto-generated method stub
}
Table creation :
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author murali
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GetNameDetails {
/**
* To retrieve the func group,func name
*
* @return @throws
* Exception
*/
public HashMap getNameDetails() throws Exception {
HashMap data = new HashMap();
HashMap nameDet = new HashMap();
String query = null;
try {
connection = DBConnection.connect();
data = new HashMap();
query = "SELECT FIRST_NAME,LAST_NAME FROM
ADDRESS";
;
stmt = connection.createStatement();
rs = stmt.executeQuery(query);
while (rs.next()) {
nameDet.put(rs.getString("FIRST_NAME"), rs
.getString("LAST_NAME"));
}
data.put("NAME DETAILS", nameDet);
} catch (Exception e) {
e.printStackTrace();
} finally {
DBConnection.close(stmt, rs, connection);
}
return data;
}
System.out.println(data1);
System.out.println("\n");
System.out.println(fetchDetails);
}
/**
* To retrieve the func group,func name from WF_FUNC_GROUP_MST
* @return @throws
* Exception
*/
public HashMap fetchDetails() throws Exception {
HashMap data = new HashMap();
HashMap details = new HashMap();
ArrayList arrayList = new ArrayList();
String query1 = null;
try {
connection = DBConnection.connect();
data = new HashMap();
query1 = "SELECT
FIRST_NAME,MI,LAST_NAME,STREET,CITY,STATE FROM ADDRESS";
stmt1 = connection.createStatement();
rs1 = stmt1.executeQuery(query1);
while (rs1.next()) {
details.put(rs1.getString("FIRST_NAME"),
rs1.getString("MI")
// rs1.getString("LAST_NAME"),
// rs1.getString("STREET"),
// rs1.getString("CITY"),
// rs1.getString("STATE")
);
}
data.put("DETAILS", details);
} catch (Exception e) {
e.printStackTrace();
} finally {
DBConnection.close(stmt1,rs1,connection);
}
return data;
}