public class test extends the HttpServlet {
Public void doGet (it the req, HttpServletResponse resp) throws ServletException, IOException {
System. The out. Println (" Hello Servlet ");
PrintWriter out=resp. GetWriter ();
Out.println (getData ());
out.flush();
out.close();
}
Protected void doPost (it the req, HttpServletResponse resp) throws ServletException, IOException {
System. The out. Println (" Hello Servlet POST ");
}
Public String getData () {
Try {
DBUtil DB=new DBUtil (" localhost ", "3306", "testDemo", "root", "123456");
DB. Connect2DB ();
List
CodePudding user response:
Using Intellij Idea development, in the doGet method of the servlet using JDBC to connect to the database is always can not find the database driver error, but in the main method to run, there is no problem, some people say that online to go through the database configuration Idea to solve, but I configuration or not ah,CodePudding user response:
CodePudding user response:
CodePudding user response:
Add the jar 'noCodePudding user response:
Solved not import in the artifactsCodePudding user response:
Didn't find drivers, there is no import drive packagesCodePudding user response:
Not in server deployment jar package, create the folder in the WEB - under the INF lib, put the jars in the folder, redeploy can solve,