You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.5 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pgr.service;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.ResultSetMetaData;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.ArrayList;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import in.gov.chennaicorporation.gccoffice.pgr.dbconnection.DBConnection;
  15. @Service
  16. public class MobileAgeAnalysisComplaintDetails {
  17. @Autowired
  18. DBConnection dbcon;
  19. public String getmobileageanalysiscomdetailsQuery(String lCmpID) {
  20. Connection connection = DBConnection.getConnection();; // Initialize your database connection
  21. System.out.println("ICmpID.............:"+lCmpID);
  22. String query = "select a.*,nvl(to_char(a.complaintdate,'dd-mm-rrrr'),' ') compdate,c.DEPT_NAME from eggr_complaintdetails@erp a,EG_DEPARTMENT@ERP c where a.deptid=c.id_dept and a.complaintid="+ lCmpID;
  23. System.out.println(query);
  24. try {
  25. PreparedStatement preparedStatement = connection.prepareStatement(query);
  26. preparedStatement.setString(1, lCmpID); // Bind the parameter
  27. ResultSet resultSet = preparedStatement.executeQuery();
  28. // Process the result set and return the result
  29. resultSet.close();
  30. preparedStatement.close();
  31. } catch (SQLException e) {
  32. // Handle any SQL errors
  33. e.printStackTrace();
  34. } finally {
  35. // Close the database connection
  36. }
  37. return query;
  38. }
  39. public List<Map<String, Object>> check(String lCmpID) {
  40. Connection con =DBConnection.getConnection();
  41. Statement stmt3;
  42. try {
  43. stmt3 = con.createStatement();
  44. System.out.println( "checkingmobileageanalysiscomplaintdetails...");
  45. ResultSet rs3 = stmt3.executeQuery(getmobileageanalysiscomdetailsQuery(lCmpID));
  46. List<Map<String, Object>> rows = new ArrayList<>();
  47. while (rs3.next()) {
  48. Map<String, Object> row = new HashMap<>();
  49. ResultSetMetaData metaData = rs3.getMetaData();
  50. int columnCount = metaData.getColumnCount();
  51. for (int i = 1; i <= columnCount; i++) {
  52. String columnName = metaData.getColumnName(i);
  53. Object columnValue = rs3.getObject(i);
  54. System.out.println(columnName+" :"+columnValue);
  55. row.put(columnName, columnValue);
  56. }
  57. rows.add(row);
  58. }
  59. return rows;
  60. }
  61. catch (Exception e){
  62. e.printStackTrace();
  63. }
  64. return null;
  65. }
  66. }