Home > Back-end >  Java calls connection mysql connection class can't call
Java calls connection mysql connection class can't call

Time:09-25

I wrote a class to connect to MySQL, then it also wrote some members of a static method, the method of connection I packed into a static method is called, but can't use this class in the servlet implementation method statement object and calls his static members, I don't know why, because when I was in the test, run separate connection of a class method is ok, but the servlet invokes the object's static method will be an error, with try catch wrapped up an error, solving, just turn off the computer, the code can't wear,

CodePudding user response:

https://blog.csdn.net/songleong/article/details/105968830

CodePudding user response:

refer to the original poster FNTP response:
I wrote a class to connect to MySQL, then some members also wrote a static method, the method of connection I packing is a static method is called, but can't use this class in the servlet implementation method statement object and calls his static members, I don't know why, because when I was in the test, run separate connection of a class method is ok, but the servlet invokes the object's static method will be an error, with try catch wrapped up an error, solving, just turn off the computer, can't wear code,



Since this is a static method, don't need a statement object, directly in the name of the class. Method calls,
  • Related