Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
at com.pak.demo.HibernateText.main(HibernateText.java:17)
<hibernate-configuration>
<session-factory>
<!-- 数据库方音 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 驱动 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 数据库连接 -->
<property name="ibernate.connection.url">jdbc:mysql:///hibernate_test</property>
<!-- 数据库用户名 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库密码 -->
<property name="hibernate.connection.password">test</property>
<!-- 自动更新表结构 -->
<property name="hhibernate.hbm2ddl.auto">update</property>
<mapping resource="com/pak/hang/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Session session = factory.openSession();Transaction tx = session.beginTransaction();User user= new User();user.setName("admin");user.setAge(10);user.setLoginTime(new Date());session.save(user);tx.commit();session.close();} }
我按视频打的~麻烦高手指出错误改怎么修改
The user must supply a JDBC connection三大框架的hibernate 今天操作报错
答案:1 悬赏:70
解决时间 2021-04-23 05:10
- 提问者网友:依靠
- 2021-04-22 06:43
最佳答案
- 二级知识专家网友:承载所有颓废
- 2021-04-22 08:11
<!-- 数据库连接 -->
<property name="ibernate.connection.url">jdbc:mysql:///hibernate_test</property>
中间有问题 jdbc:mysql://localhost:3306/hibernate_test
其中localhost是数据库所在主机的IP地址,本机就是localhost,
3306是默认端口号
hibernate_test是你对应的数据库名,
<property name="ibernate.connection.url">jdbc:mysql:///hibernate_test</property>
中间有问题 jdbc:mysql://localhost:3306/hibernate_test
其中localhost是数据库所在主机的IP地址,本机就是localhost,
3306是默认端口号
hibernate_test是你对应的数据库名,
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯