Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/21/2020 in all areas

  1. Good work, now we can see the root cause exception and read its message, which is [User ja190823_R already has more than 'max_user_connections' active connections] So it failed because your user is making too many connections to the database. I think this is because you are making a new connection for each one of your JSP requests. Try to call [close] on the Connection when you are done with it. Also, typically the management of connections, creation, pooling and reuse of them and so on is handled for you by the application container or servlet you are using. For example, with Tomcat, you can set up a database in the context using context.xml or server.xml and then in your program get the connection using InitialContext. This gets better performance than always creating/closing connections. If you are interested in learning about this, here are some documentations. Here is a document on how to set up the resource: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-usagenotes-tomcat.html And this document has an example of how you can get that connection by use of DataSource and InitialContext https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-usagenotes-j2ee-concepts-connection-pooling.html#connector-j-examples-connectionpool-j2ee
    1 point
  2. This is what I think is going on and how I suggest you debug it: The NullPointerException you see is because your [DbConnection.getconnection()] call is returning null. You see that message in your browser because [out] in the JSP page is set up to "write there". In your [DbConnection.getconnection()] method, you set the connection to null. Then in your try block, an exception happens, you catch and print that exception, and return the null. You don't see the exception because you use [system.out.println] and that write to the stdout of the JVM Catalina is using. Usually Tomcat setups redirect that to a log file. There are 2 things in your [try] block that are likely to fail with an exception. The first is a problem coming from the classloader when you use it to load the driver. The second is when you connect to the database. To understand what is going wrong, seeing what exception you received would be helpful. To see that, you have to look in the catalina logs to see if the exception message you printed to stdout was redirected to there. Or, better, change your method to NOT swallow and print the exception to stdout. For your debugging, either don't catch the exception, or if you do want to print it, rethrow it after. Then the root cause exception, and not just a null, will be trapped and handled in the try/catch block in your JSP page, and you can see it on the browser.
    1 point
  3. Seriously. I edited the first one to strip out all the HTML, but I'm not going to do that for all of his posts.
    1 point
  4. In your DbConnection class, if there is an exception constructing the connection, you are catching it and using System.out.println, then returning the null connection. Printing it that way won't show you the error message in the browser, it goes to the stdout of the JVM running Tomcat. It might help you to understand what is going wrong if you can see that exception during the JDBC connection attempt. You could try debugging by just not catching or rethrowing it. Or look in the tomcat log files, usually System.out is set up to redirect to one of them. The exception you have shown is coming from the null returned by your static method, but it can't show information about why it was null. Also, the formatting of your post makes it very hard to read.
    1 point
  5. 1 point
×
×
  • Create New...