From 6883bbdf3784e148ab9fe31d64001738c0fa795c Mon Sep 17 00:00:00 2001 From: chandrasegar Date: Mon, 26 Feb 2024 11:07:00 +0530 Subject: [PATCH] table and column names changed to Upper --- .../mailsender/DAO/Impl/MailDAOImpl.java | 28 +++++++++---------- src/main/resources/application.properties | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/entgra/mailsender/DAO/Impl/MailDAOImpl.java b/src/main/java/entgra/mailsender/DAO/Impl/MailDAOImpl.java index 45c886a..4f32bbf 100644 --- a/src/main/java/entgra/mailsender/DAO/Impl/MailDAOImpl.java +++ b/src/main/java/entgra/mailsender/DAO/Impl/MailDAOImpl.java @@ -38,7 +38,7 @@ public class MailDAOImpl implements MailDAO { PreparedStatement stmt; int generatedId; Connection conn = this.getConnection(); - stmt = conn.prepareStatement("INSERT INTO email (EMAIL_ADDRESS, MSG_TEMPLATE, PRIORITY, ATTACHMENT, PARAMETERS, TIME, FILENAME, EXPIRY_AT) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS); + stmt = conn.prepareStatement("INSERT INTO EMAIL (EMAIL_ADDRESS, MSG_TEMPLATE, PRIORITY, ATTACHMENT, PARAMETERS, TIME, FILENAME, EXPIRY_AT) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS); Timestamp current_time = new Timestamp(System.currentTimeMillis()); String parametersJson = new ObjectMapper().writeValueAsString(mailModel.getParameters()); stmt.setString(1, mailModel.getEmailAddress()); @@ -70,7 +70,7 @@ public class MailDAOImpl implements MailDAO { @Override public List getUnsentMessages() { - String sql = "SELECT * FROM email WHERE email_id NOT IN (SELECT email_id FROM sentEmail)"; + String sql = "SELECT * FROM EMAIL WHERE EMAIL_ID NOT IN (SELECT EMAIL_ID FROM SENTEMAIL)"; List unsentMails = new ArrayList<>(); @@ -79,9 +79,9 @@ public class MailDAOImpl implements MailDAO { ResultSet rs = statement.executeQuery()) { while (rs.next()) { MailModel mailModel = new MailModel(); - mailModel.setEmailId(rs.getInt("email_id")); - mailModel.setPriority(rs.getInt("priority")); - mailModel.setExpiry_at(rs.getDate("expiry_at")); + mailModel.setEmailId(rs.getInt("EMAIL_ID")); + mailModel.setPriority(rs.getInt("PRIORITY")); + mailModel.setExpiry_at(rs.getDate("EXPIRY_AT")); unsentMails.add(mailModel); } } catch (SQLException e) { @@ -94,7 +94,7 @@ public class MailDAOImpl implements MailDAO { @Override public MailModel getMailDetails(Integer mail_id) { - String sql = "SELECT * FROM email WHERE email_id = ?"; + String sql = "SELECT * FROM EMAIL WHERE EMAIL_ID = ?"; MailModel mailModel = new MailModel(); try { @@ -103,19 +103,19 @@ public class MailDAOImpl implements MailDAO { stmt.setInt(1, mail_id); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { - mailModel.setEmailId(rs.getInt("email_id")); - mailModel.setEmailAddress(rs.getString("email_address")); - mailModel.setMsgTemplate(rs.getString("msg_template")); - mailModel.setPriority(rs.getInt("priority")); + mailModel.setEmailId(rs.getInt("EMAIL_ID")); + mailModel.setEmailAddress(rs.getString("EMAIL_ADDRESS")); + mailModel.setMsgTemplate(rs.getString("MSG_TEMPLATE")); + mailModel.setPriority(rs.getInt("PRIORITY")); - String jsonData = rs.getString("parameters"); + String jsonData = rs.getString("PARAMETERS"); List parameters = parseJsonParameters(jsonData); mailModel.setParameters(parameters); - String filename = rs.getString("filename"); + String filename = rs.getString("FILENAME"); mailModel.setFilename(filename); - Blob blob = rs.getBlob("attachment"); + Blob blob = rs.getBlob("ATTACHMENT"); File file = convertBlobToFile(blob, filename); mailModel.setFile(file); } @@ -161,7 +161,7 @@ public class MailDAOImpl implements MailDAO { try { PreparedStatement stmt; Connection connection = this.getConnection(); - stmt = connection.prepareStatement("INSERT INTO sentEmail (email_id,sent_time) VALUE (?,?)"); + stmt = connection.prepareStatement("INSERT INTO SENTEMAIL (EMAIL_ID,SENT_TIME) VALUE (?,?)"); stmt.setInt(1, mail_id); stmt.setDate(2, Date.valueOf(LocalDate.now())); stmt.execute(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4786a42..d6b69fd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,9 +2,9 @@ spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username=chandrasegar@entgra.io spring.mail.password=kfgt idre luvt ismk -spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/email_sending -spring.datasource.username=entgra -spring.datasource.password=entgra123 +spring.datasource.url=jdbc:mysql://localhost:3306/email_sending +spring.datasource.username=root +spring.datasource.password=StrongPassword123! spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver