首先,我不能找到在这个论坛相关问题的答案。我是Hibernate技术的新手,我试图从这个页面运行一个基本示例:http://www.roseindia.net/hibernate/hibernate4/firstHibernateApplication.shtml 尽管在eclipse中它工作正常,但Intellij IDEA存在问题。具体来说,我在hibernate.cfg.xml文件中有一个错误,它说:的IntelliJ错误:找到了JDBC没有合适的驱动程序的:mysql://127.0.0.1:3306 /人
“'com.mysql.jdbc.Driver'不能分配给'java.sql.Driver'”。
当我运行程序时出现一条消息说: “ERROR:找到JDBC没有合适的驱动程序的:mysql://127.0.0.1:3306 /人插入记录无法打开连接”
(”人'是我的数据库)我已经添加了必要的jar文件(或者至少我认为是这样),并且通常我已经按照我在此消息的第二行粘贴的网页中的所有步骤进行了操作。请看看它,如果可以的话,帮助我。我所创建的所有文件和代码都可以从我粘贴的网站上看到。我几乎已经复制了这个例子。谢谢。
修订
hibernate.cfg.xml中:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/person
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"/>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
我已经放置在连接器的jar文件在目录IdeaProjects \ coreHibernateExample \ lib中。不,我没有运行Tomcat,我想我正在运行Intellij。 Mysql数据库的导入通过Wampservers的phpmyadmin完成。
你能发布你的配置文件吗?另外,你能告诉我(我们)是否自己或通过IntelliJ运行Tomcat(或任何应用程序服务器)?另外,你在哪里放置了MySQL Connector/j Jar文件? – Mike 2013-04-22 19:09:17