diff --git a/pom.xml b/pom.xml index 1b0d4ad..72835a2 100644 --- a/pom.xml +++ b/pom.xml @@ -18,9 +18,11 @@ provided - mysql - mysql-connector-java - 5.1.30 + com.mysql + mysql-connector-j + 8.4.0 + + provided junit diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index 8f4a4ba..60aa483 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -2,8 +2,10 @@ <% String userName = request.getParameter("userName"); String password = request.getParameter("password"); - Class.forName("com.mysql.jdbc.Driver"); - Connection con = DriverManager.getConnection("jdbc:mysql://mydb.c1g5t3oofrok.us-west-2.rds.amazonaws.com:3306/jwt","ravi", "Admin123*"); + // DB settings come from Tomcat's environment (written to setenv.sh when the instance boots) + String dbUrl = "jdbc:mysql://" + System.getenv("DB_HOST") + ":" + System.getenv("DB_PORT") + "/" + System.getenv("DB_NAME"); + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection con = DriverManager.getConnection(dbUrl, System.getenv("DB_USER"), System.getenv("DB_PASS")); Statement st = con.createStatement(); ResultSet rs; rs = st.executeQuery("select * from USER where userName='" +userName + "' and password='" +password + "'"); diff --git a/src/main/webapp/userRegistration.jsp b/src/main/webapp/userRegistration.jsp index 4c9142c..aad5cb2 100644 --- a/src/main/webapp/userRegistration.jsp +++ b/src/main/webapp/userRegistration.jsp @@ -5,8 +5,10 @@ String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); String email = request.getParameter("email"); - Class.forName("com.mysql.jdbc.Driver"); - Connection con = DriverManager.getConnection("jdbc:mysql://mydb.c1g5t3oofrok.us-west-2.rds.amazonaws.com:3306/jwt", "ravi", "Admin123*"); + // DB settings come from Tomcat's environment (written to setenv.sh when the instance boots) + String dbUrl = "jdbc:mysql://" + System.getenv("DB_HOST") + ":" + System.getenv("DB_PORT") + "/" + System.getenv("DB_NAME"); + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection con = DriverManager.getConnection(dbUrl, System.getenv("DB_USER"), System.getenv("DB_PASS")); Statement st = con.createStatement(); int i = st.executeUpdate("insert into USER(first_name, last_name, email, username, password, regdate) values ('" + firstName + "','" + lastName + "','" + email + "','" + userName + "','" + password + "', CURDATE())");