table and column names changed to Upper

exception
parent 8a50747ffd
commit 6883bbdf37

@ -38,7 +38,7 @@ public class MailDAOImpl implements MailDAO {
PreparedStatement stmt; PreparedStatement stmt;
int generatedId; int generatedId;
Connection conn = this.getConnection(); 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()); Timestamp current_time = new Timestamp(System.currentTimeMillis());
String parametersJson = new ObjectMapper().writeValueAsString(mailModel.getParameters()); String parametersJson = new ObjectMapper().writeValueAsString(mailModel.getParameters());
stmt.setString(1, mailModel.getEmailAddress()); stmt.setString(1, mailModel.getEmailAddress());
@ -70,7 +70,7 @@ public class MailDAOImpl implements MailDAO {
@Override @Override
public List<MailModel> getUnsentMessages() { public List<MailModel> 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<MailModel> unsentMails = new ArrayList<>(); List<MailModel> unsentMails = new ArrayList<>();
@ -79,9 +79,9 @@ public class MailDAOImpl implements MailDAO {
ResultSet rs = statement.executeQuery()) { ResultSet rs = statement.executeQuery()) {
while (rs.next()) { while (rs.next()) {
MailModel mailModel = new MailModel(); MailModel mailModel = new MailModel();
mailModel.setEmailId(rs.getInt("email_id")); mailModel.setEmailId(rs.getInt("EMAIL_ID"));
mailModel.setPriority(rs.getInt("priority")); mailModel.setPriority(rs.getInt("PRIORITY"));
mailModel.setExpiry_at(rs.getDate("expiry_at")); mailModel.setExpiry_at(rs.getDate("EXPIRY_AT"));
unsentMails.add(mailModel); unsentMails.add(mailModel);
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -94,7 +94,7 @@ public class MailDAOImpl implements MailDAO {
@Override @Override
public MailModel getMailDetails(Integer mail_id) { 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(); MailModel mailModel = new MailModel();
try { try {
@ -103,19 +103,19 @@ public class MailDAOImpl implements MailDAO {
stmt.setInt(1, mail_id); stmt.setInt(1, mail_id);
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) { while (rs.next()) {
mailModel.setEmailId(rs.getInt("email_id")); mailModel.setEmailId(rs.getInt("EMAIL_ID"));
mailModel.setEmailAddress(rs.getString("email_address")); mailModel.setEmailAddress(rs.getString("EMAIL_ADDRESS"));
mailModel.setMsgTemplate(rs.getString("msg_template")); mailModel.setMsgTemplate(rs.getString("MSG_TEMPLATE"));
mailModel.setPriority(rs.getInt("priority")); mailModel.setPriority(rs.getInt("PRIORITY"));
String jsonData = rs.getString("parameters"); String jsonData = rs.getString("PARAMETERS");
List<MailModel.Parameter> parameters = parseJsonParameters(jsonData); List<MailModel.Parameter> parameters = parseJsonParameters(jsonData);
mailModel.setParameters(parameters); mailModel.setParameters(parameters);
String filename = rs.getString("filename"); String filename = rs.getString("FILENAME");
mailModel.setFilename(filename); mailModel.setFilename(filename);
Blob blob = rs.getBlob("attachment"); Blob blob = rs.getBlob("ATTACHMENT");
File file = convertBlobToFile(blob, filename); File file = convertBlobToFile(blob, filename);
mailModel.setFile(file); mailModel.setFile(file);
} }
@ -161,7 +161,7 @@ public class MailDAOImpl implements MailDAO {
try { try {
PreparedStatement stmt; PreparedStatement stmt;
Connection connection = this.getConnection(); 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.setInt(1, mail_id);
stmt.setDate(2, Date.valueOf(LocalDate.now())); stmt.setDate(2, Date.valueOf(LocalDate.now()));
stmt.execute(); stmt.execute();

@ -2,9 +2,9 @@ spring.mail.host=smtp.gmail.com
spring.mail.port=587 spring.mail.port=587
spring.mail.username=chandrasegar@entgra.io spring.mail.username=chandrasegar@entgra.io
spring.mail.password=kfgt idre luvt ismk spring.mail.password=kfgt idre luvt ismk
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/email_sending spring.datasource.url=jdbc:mysql://localhost:3306/email_sending
spring.datasource.username=entgra spring.datasource.username=root
spring.datasource.password=entgra123 spring.datasource.password=StrongPassword123!
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Loading…
Cancel
Save