更新时间:2022-04-11 09:14:48
如果您在进行首次连接之前未加载驱动程序,则可能会发生这种情况.
That can happen if you didn't load the driver before making the first connection ever.
Class.forName("com.mysql.jdbc.Driver");
可以肯定的是,驱动程序必须进入/WEB-INF/lib
,而不是进入/WEB-INF
.顺便说一下,您那里有一些SQL注入漏洞.看PreparedStatement
. finally
也可以进行改进,就像现在一样,con
不会在rs.close()
引发异常时关闭.
To be sure, the driver has to go in /WEB-INF/lib
, not in /WEB-INF
. You've there by the way some SQL injection holes. Look at PreparedStatement
. The finally
can also be improved, as you have it now, the con
will never be closed when rs.close()
throws an exception.