rohanawaw Posted December 5, 2018 Share Posted December 5, 2018 (edited) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'rajesha1_azhar'@'localhost' to database 'rajesha1__password' with this code Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/rajesha1__password","rajesha1_azhar", "pass"); working fine on my machine Edited December 5, 2018 by rohanawaw Quote Link to comment Share on other sites More sharing options...
wolstech Posted December 5, 2018 Share Posted December 5, 2018 Did you assign the user to the database in cpanel and grant it rights to use it? Quote Link to comment Share on other sites More sharing options...
rohanawaw Posted December 5, 2018 Author Share Posted December 5, 2018 (edited) all preveliges are given, user assign to database solved database name was wrong _ instead of __ Edited December 5, 2018 by rohanawaw Quote Link to comment Share on other sites More sharing options...
wolstech Posted December 5, 2018 Share Posted December 5, 2018 That would do it. Glad to see you figured it out Quote Link to comment Share on other sites More sharing options...
rohanawaw Posted December 5, 2018 Author Share Posted December 5, 2018 nowjavax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. i guess the same old problem of not closing the connectio in database rs.close(); st.close(); conn.close(); where to put these lines exactly Quote Link to comment Share on other sites More sharing options...
rohanawaw Posted December 5, 2018 Author Share Posted December 5, 2018 (edited) nowjavax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.my code <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><%boolean ok=false; String req_pass=request.getParameter("pass"); String req_motherboard_id=request.getParameter("mot_id"); String req_cpu_id=request.getParameter("cpu_id"); String req_mac_id=request.getParameter("mac_id"); // String ProductNamez=request.getParameter("ProductName"); Connection conn=null; Statement st=null; ResultSet rs=null;try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/rajesha1_password","rajesha1_azhar", "pass"); st=conn.createStatement(); rs = st.executeQuery("SELECT * FROM machineid WHERE pass = '"+ req_pass +"' "); while(rs.next()){ if(rs.getString(3).equals(req_mac_id)) { } if(rs.getString(2).equals(req_cpu_id)) { } if(rs.getString(1).equals(req_motherboard_id)) { ok=true; } } //rs.close(); // st.close(); // conn.close(); }catch(Exception e){out.println(e.getMessage()) ;} %> <%if(!ok){ // String ProductNamez=request.getParameter("ProductName");try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); st=conn.createStatement();conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/rajesha1_password","rajesha1_azhar", "pass"); rs = st.executeQuery("SELECT count(*) FROM machineid WHERE pass = '"+req_pass +"' "); while(rs.next()){ int h= rs.getInt(1); if(h<5) { String sql = "INSERT INTO machineid " + "VALUES ('"+req_motherboard_id+"', '"+req_cpu_id+"', '"+req_mac_id+"','"+req_pass+"')"; int rsu = st.executeUpdate(sql); } } //PrintWriter output = response.getWriter(); out.println("yes"); //String no="no"; //respose.send("yes");} catch(Exception e) { out.println(e.getMessage()); } }else{String no="no";out.println("no"); rs.close(); st.close(); conn.close(); } out.println("yes"); %></body></html> operation not allow after resultset close Edited December 5, 2018 by rohanawaw Quote Link to comment Share on other sites More sharing options...
Krydos Posted December 5, 2018 Share Posted December 5, 2018 My guess would be that you're opening too many mysql connections. Tomcat has a tendency to try to open 100s of connections unless you limit it. Quote Link to comment Share on other sites More sharing options...
Luigi123 Posted December 5, 2018 Share Posted December 5, 2018 Moved to Customer Service. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.