jsp - how can i solve this error, javax.servlet.ServletException: java.sql.SQLException: No database selected -
I am a newbie in webapp developement, I have this code login.jsp and registration.jsp, log me jsps These should do and register but this is not the case, when I try to login or register at any time, I get this error message "javax.servlet.ServletException: java.sql.SQLException: no database selected ". This is related to my code, please tell me what to do, correct me where I am wrong Thanks for the help. Make 'tab' member '(`id`in int (10) unsigned not auto_interment,' email 'varchar (45) no,' unmatched 'varchar (45) not tap,` password` Varchar (45) is not 'passwordsignup_confirm` varchar (45) no primary key (`id`) engine = InnoDB DEFAULT CHARSET = latin1; Login.jsp & lt;% @ page import = "java.sql. *"% & Gt; & Lt;% string userid = request.getParameter ("uname"); String email = request.getParameter ("emailignup"); String password = request.getParameter ("password"); Class.forName ("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection ("jdbc: mysql: // localhost: 3306", "root", "shaddy"); Description st = con.createStatement (); Reset the result; Rs = st.executeQuery (select "WHERE uname = '" + userid + "', '" + + + + "+"' and password = '"+ +" + "+" "' '); if (rsnext ()) {Session.setAttribute ("userid", userid); Out.println ("welcome" + user id); Out.println ("& lt; a href = 'logout.jsp' & gt; logout & lt; / a & Gt; "); response.sendRedirect (" success.jsp ");} Other {out.println (" Invalid Password & lt; a href = 'index.jsp' & gt; Try again & lt; / a & Gt; ");}% & Gt; Registration. Zap & lt;% @ Page Import =" Java SQL. String password = request.getParameter ("password"); string passwordguoin_product = string = request.getParameter ("emailignup"); string = username = request.getParameter ("uname"); string; Request.getParameter ("passwordsignup_confirm"); String usernames insins = request.getParameter ("usernamesignup"); string passwordguide = request.getParameter ("password guine"); Class.forName ("com.mysql.jdbc.Driver"); connection Con = driverManager.getConnection ("jdbc: mysql: // localhost: 3306", "root", "shaddy"); description st = con.createStatement (); // result russetset; int i = st.executeUpdate ("member (Uname, email, password,) Enter the values ('+ username' + '', '+ + + + + +' ',' + + + + + ',' '+ passwordwordsup_confirm + "' '); if (i> gt; 0) {session ;setAttribute ("userid", username); response.sendRedirect ("welcome.jsp"); out.print ("Registration Successful!" + "& Lt; a href = 'Index.jsp' & gt; Login & Lt; / a & gt; ");} Other {response.sendRedirect (" index.jsp ");}%> You are missing the database name in the URL, your database name : ("Uname, email, password,) value ('" + +' ',' + + + + + + '', '"+ + + +' ',' + + + passwordwordsup_confirm + '' ') ); Add a brace like this above.
DriverManager.getConnection ("jdbc: mysql: //
" jdbc: mysql: // localhost: "" local host: 3306 "," root "," shady ");
Comments
Post a Comment