Hi everyone,
My current lab / homework has me stumped. In my class file name LocalMySQL.java It seems like the database connection is null but I don't understand why it's null.
Everything I do to try and
test this seems to show that a connection is being made. I have a
servlets ( name ServletEED) which should use the connection information found on LocalMySQL class. It is returning the error I created for when the connection isn't available.
In my class file I added a System.out.print("THIS WORKS ") to print out "THIS WORKS " thinking that this would only print out if the connection was being made. I guess that's not the case? "THIS WORKS" prints out to my console but it's followed by "Error" which I added in the Main method.
I created a servlet that connects to the same databases and table and was able to run a sql statement via. a servlet and the sql statement worked. My only thoughts is perhaps the connection object created in openDB() is being closed right after it is called? My other thought is perhaps I just don't really understand what a connection object is and my error checking is wrong.
Help please. How do I maintain this connection I need or why is it not available to my ServletEED? Ultimately I need my ServletEED to be able to establish a connection using my LocalMySQL class file . As it is right now I'm not able to move forward with the rest of my lab.
Thank You all so much!
Here is the LocalMySQL class
Here is the servlete which uses the LocalMySQ class file.
This is the servlet I created to query my database and it works.