2. * @param mode
* @return
*/
public Exception performRequest(Connection conn, String
mode, String opCode){
PreparedStatement ps = null;
ResultSet rs = null;
Exception e = null;
//Defines a sort order
String sortOrder = "ASC";
if("2".equals(opCode)){
sortOrder = "DESC";
}
switch(mode){
case "1":
try {
3. String sql = "SELECT * FROM [User]";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "2":
try {
String sql = "SELECT * FROM [User] A"+
" Left Join Address As B on A.UserId = B.UserId"+
4. "Left Join Phone As C on C.UserId = A.UserId";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "3":
try {
String sql = "SELECT * FROM
[Order_Hdr] A"+
" Left Join [User] (FirstName), (LastName), (Email)
As B on A.UserId = B.UserId";
}
6. catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "5":
try {
String sql = "SELECT (Message) FROM
[System_Log] A"+
" Left Join [Company] As B on A.UserId =
B.UserId"+
"Left Join [Location] As C on C.UserId = A.UserId"
+"GROUP BY LogType"
+"ORDER BY (CompanyId,LocationId)";
}
catch(Exception ex)
{
7. System.out.println(e.toString());
}
break;
case "6":
try {
String sql = "SELECT (Message) FROM
[System_Log] A"+
" Left Join [Company] As B on A.UserId =
B.UserId"+
"Left Join [Location] As C on C.UserId = A.UserId"
+"WHERE (Region)= ENGLAND"
+"GROUP BY LogType"
+"ORDER BY (CompanyId,LocationId)";
}
catch(Exception ex)
{
System.out.println(e.toString());
8. }
break;
case "7":
try {
String sql = "SELECT * FROM
[Order_Dtl] A"+
" Left Join [Production_Dtl] As B on A.ProductId =
B.ProductId"
+" WHERE B.ProductionId =
null";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
9. break;
case "8":
try{ String sql = "DELETE FROM [User] WHERE
Email= [email protected]";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "9":
try{ String sql = "SELECT (Email) FROM
[User] A"+
" Left Join Address As B on A.UserId =
B.UserId"+
"Left Join Phone As C on C.UserId =
10. A.UserId"
+ "UPDATE FROM [Address] WHERE Email=
[email protected]"
+"UPDATE FROM [Address]" +"WHERE
UserId=15"
+"UPDATE FROM [Address]" +"WHERE
UserId=15";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "10":
try {
11. String sql = "SELECT SUM (UnitsOnHand)
FROM [Production_Dtl] A"+
" Left Join [Company] As B on A.UserId =
B.UserId"+
"Left Join [Location] As C on C.LocationId =
B.LocationId"
+"WHERE (Region)= United States"
+"GROUP BY ProductId";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "11":
try {
String sql = "SELECT SUM (UnitsCost)
FROM [Production_Dtl] A"+
12. " Left Join [Company] As B"+
"Left Join [Product] As C on C.LocationId =
A.LocationId"
+"GROUP BY ProductId";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "12":
try {
String sql = "SELECT SUM (UnitsCost)
FROM [Production_Dtl] A"+
" Left Join [Company] As B"+
"Left Join [Product] As C on C.LocationId =
A.LocationId"
13. +"GROUP BY ProductDesc";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
break;
case "13":
try {
String sql = "SELECT (CompanyDesc)
FROM [Company] A"+
" Join [Production_Dtl] As B "+
"Left Join [Production_Hdr] As C on C.ProductionId
= B.ProductionId"
+"WHERE (ProductionId)=null"
+"GROUP BY ProductId";
15. }
break;
case "15":
try {
String sql = "SELECT top 1 FROM
[Order_Hdr] A"+
" Join [User] As B "+
"Order by A.OrderQty Desc";
}
catch(Exception ex)
{
System.out.println(e.toString());
}
16. break;
case "16":
String sql = "SELECT * FROM [Product]
A"+
" Left Join [Production_Hdr] As B on A.Description =
B.Description"
+"Left Join [Production_Dtl] as C "
+"Left Join [Orders] as D "
+"Order By (C.UnitsOnHand,
C.UnitsCost) ";
break;
default:
e = new Exception ("Invalid mode. Mode: " +
mode);
};
return e;
}
public Exception performRequest(Connection conn, String
x) {