I am new in java there is a piece of code which is written in if-else i want to change this to switch statement but i have no idea to write in switch statement.Here is my code.
<%
String userid = request.getParameter("username");
String pwd = request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/auto_lube","root", "password");
Statement st = con.createStatement();
ResultSet rs; `rs = st.executeQuery("select * from users where uname='" + userid + "' and pass='" + pwd + "' and role='users'");`
if (rs.next()) {
String username = rs.getString("uname");
String email = rs.getString("email");
session.setAttribute("customer_name", username);
int user = rs.getInt("id");
session.setAttribute("customer_id", user);
if(dat.after(date)){
MailClient client = new MailClient();
String from="username@gmail.com";
String to = email;
String subject="Please Attention";
String message="Please change your vehicles oil today is expiery date?";
client.sendMail(from,to,subject,message);}
//out.println("welcome " + userid);
//out.println("<a href='logout.jsp'>Log out</a>");
response.sendRedirect("index.jsp");
} else {
response.sendRedirect("invalid.jsp");
}