我正在尝试使用hibernate 5.2.10版本创建一个基本的hibernate应用程序。当我运行它时说
org.hibernate.HibernateException: Unable to make JDBC Connection [jdbc:mysql//localhost:3306/hibernatedb]
hibernate.cfg.xml中:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:mysql//localhost:3306/hibernatedb</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.hbm2ddl.auto">udpate</property>
<mapping class="com.chandu.app.model.UserDetails"/>
</session-factory>
主要课程:
public class HibernateTest {
public static void main(String[] args) {
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
UserDetails user = getUserObject();
session.save(user);
session.getTransaction().commit();
session.clear();
}
private static UserDetails getUserObject() {
UserDetails user = new UserDetails();
user.setUserName("Test User");
return user;
}
控制台:
代码结构:
我已经浏览了一些论坛,但无法找到相同的解决方案。 谢谢你的帮助!