Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SQL code along with connection utility #23

Closed
wants to merge 36 commits into from
Closed

Conversation

alanpjohn
Copy link
Owner

With reference to #22

Queries added

Authors: @Rashmikareddya @sushmadammalapati

  • SQL queries for table creation added
  • SQL trigger for amenities update
  • SQL trigger for feedback update

SQLCredentialsUtil

Author : @TheForeverLost

com.hsbc.meets.util.SQLCredentialsUtil

This class reads MySQL database credentials stored at src/main/webapp/WEB_INF/connection.prop. I have added to gitignore the connection.prop file so that no one pushes it because it has credentials so security issues annd it may not be the same for all of us as we are all going to be using local database.

So you'll all have to create connnection.prop files in the location specified and use this class to retrieve the properties. Till you merge with this branch, you can use store the properties in the code itself

Below is a sample connection.prop file

dname=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/database 
username=username
password=password

Also created is a InvalidPropFileException which is thrown whenever the properties could not be read properly

Copy link
Collaborator

@rishikeshshede rishikeshshede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@ShubhraBhuniaGhosh
Copy link
Collaborator

explain what is this later

Copy link
Collaborator

@pavleen14 pavleen14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me, we can move ahead with this.

@alanpjohn
Copy link
Owner Author

alanpjohn commented Sep 21, 2021

explain what is this later

@ShubhraBhuniaGhosh

Currently you have put your database credentials in the code

That is not appropriate in an application. So instead, you will put these credentials in a file called connection.prop stored at src/main/webapp/WEB_INF/connection.prop in the project folder.

and then use the com.hsbc.meets.util.SQLConnectionCredentials.readCredentials() (static method) to get a com.hsbc.meets.util.SQLConnectionCredentials object which store your credentials in your constructor and use this to create your connection.

something on these lines

import com.hsbc.meets.util.SQLConnectionCredentials;

public class SomeDaoImpl{
    
    public SomeDaoImpl(){
		try{
        SQLConnectionCredentials creds = SQLConnectionCredentials.readCredentials();
            String driverName = creds.getDriverName();
            String username = creds.getUsername();
            String password = creds.getPassword();
            String url = creds.getUrl();
        }catch(InvalidPropFileException e){
            /*
            Your error handling
            */
        }
        /*
        Add your connection estabilishment code here
        /*
    }
}

@ShubhraBhuniaGhosh
Copy link
Collaborator

explain what is this later

@ShubhraBhuniaGhosh

Currently you have put your database credentials in the code

That is not appropriate in an application. So instead, you will put these credentials in a file called connection.prop stored at src/main/webapp/WEB_INF/connection.prop in the project folder.

and then use the com.hsbc.meets.util.SQLConnectionCredentials.readCredentials() (static method) to get a com.hsbc.meets.util.SQLConnectionCredentials object which store your credentials in your constructor and use this to create your connection.

something on these lines

import com.hsbc.meets.util.SQLConnectionCredentials;

public class SomeDaoImpl{
    
    public SomeDaoImpl(){
		try{
        SQLConnectionCredentials creds = SQLConnectionCredentials.readCredentials();
            String driverName = creds.getDriverName();
            String username = creds.getUsername();
            String password = creds.getPassword();
            String url = creds.getUrl();
        }catch(InvalidPropFileException e){
            /*
            Your error handling
            */
        }
        /*
        Add your connection estabilishment code here
        /*
    }
}

got it thank u

@@ -1,3 +1,6 @@
CFEATE database projectdatabase;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should name our database something more appropriate to the project

@alanpjohn alanpjohn closed this Sep 26, 2021
@alanpjohn alanpjohn deleted the database branch September 27, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants