简体   繁体   English

严重:找不到合适的驱动程序(MySQL)

[英]SEVERE: No suitable driver found (MySQL)

I have a web based application where each three seconds i connect to a database and query data from gps devices. 我有一个基于Web的应用程序,每三秒钟我连接到一个数据库并从gps设备查询数据。

Unfortunatelly when the application works for more than few hours out of no where i get the exception: "SEVERE: No suitable driver found for jdbc .... ". 不幸的是,当应用程序工作超过几个小时时,我得到异常:“严重:没有为jdbc找到合适的驱动程序....”。 The application still works and connects to the database but the message get prints each time i request new data. 应用程序仍然可以工作并连接到数据库,但每次请求新数据时都会打印消息。

Why do i get this exception? 为什么我会得到这个例外? Why it appears only after a few hours of work? 为什么它只在经过几个小时的工作后出现?

Any solution? 有解决方案吗

Maybe somewhere you have placed an ill-formed database connection URL for which your DriverManager cannot find a suitable driver. 也许在某处您放置了一个格式错误的数据库连接URL,您的DriverManager无法找到合适的驱动程序。

For example, say you need an URI like "jdbc:mysql://my_database_host/test" and somewhere in your code there is a "jdbc:MySql://my_database_host/test" which would fail. 例如,假设您需要一个类似“jdbc:mysql:// my_database_host / test”的URI,并且在代码中的某处有一个“jdbc:MySql:// my_database_host / test”,它将失败。

However, I think that the real problem lies here: 但是,我认为真正的问题在于:

I have a web based application where each three seconds i connect to a database 我有一个基于Web的应用程序,每三秒钟我连接到一个数据库

I suggest you that you consider changing this design to a managed connection pool, be it your application server native one, or the implementation you like the most (dbcp, c3p0, etc.). 我建议您考虑将此设计更改为托管连接池,无论是您的应用程序服务器本机,还是您最喜欢的实现(dbcp,c3p0等)。 This way your application will gain performance (you will work with a set of connections opened beforehand, so you save the time and headaches to be opening them) and scalability (does your application open connections frequently for each request? Have you considered the consequences to do so in a frequently requested production environment? Much better to have a limit to open connections) 通过这种方式,您的应用程序将获得性能(您将使用预先打开的一组连接,因此您可以节省打开它们的时间和麻烦)和可伸缩性(您的应用程序是否经常为每个请求打开连接?您是否考虑过后果?在频繁请求的生产环境中这样做?更好地限制打开连接)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM