简体   繁体   中英

Intellij IDEA Hibernate Console not finding JDBC Driver

I am trying to use the Hibernate Console to query my database. My project is currently set up to use Hibernate. However, whenever I try a simple query, I get an error saying that the JDBC Driver cannot be found. 在此处输入图片说明

I currently have mysql-connector on my classpath 在此处输入图片说明

I'm really not sure what else to do. I think everything should be working, and it's not. Does anyone have any advice?

Edit

I checked the Data Sources and Drivers and confirmed that Intellij knows where a MySQL driver is. I know it works because I issued sql queries using the MySQL console.

在此处输入图片说明

I was able to resolve the JDBC Driver class not found Exception. I right clicked on a sessionFactory and selected "Assign Data Sources". Then I selected the MySQL data source. Before it was "none". Now everything is working

在此处输入图片说明

It looks like your secind screenshot is coming from the module settings, is that right? I don't think IntelliJ will use the project .m2 when formulating internal dependencies/classpath details.

Do you have the database driver setup in the database widget (usually docked to the right hand side of IntelliJ)? From here you can setup your database connections, and download appropriate JDBC drivers.

Take this screenshot for example, IntelliJ has downloaded the MySQL Drivers and the are in /Users/acanby/Library/Preferences/IntelliJIdea14/... , not a maven .m2 directory:

数据源和驱动程序

I would expect IntelliJ to not know how to connect to MySQL databases until the appropriate driver is downloaded. Can you check to ensure it is downloaded? Database widget > Data Sources and Drivers > Drivers > MySQL . If it is not downloaded, download it and try again.

将mysql-connector-java-version-bin.jar文件拖放到您的项目中,右键单击它,选择“添加为库”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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