今天在配置hibernate之后,进行单元测试,运行中报出了
the user must supply a jdbc connection 这个错误
回头看了一下配置文件,这是hibernate的属性配置写错了,我使用了spring bean的property属性写法
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
正确的hibernate配置应该是这样的:
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle9iDialect
</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="connection.url">
jdbc:oracle:thin:@XX.XX.XXX.XX:1521:XXX
</property>
<mapping resource="hibernate/TblScheduleTemplate.hbm.xml" />
</session-factory>
</hibernate-configuration>
这里的property属性 写法和Spring的不同,之前有一个Spring和hibernate整合的,那个地方配置文件是Spring中的,写成了:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="jdbcUrl" value="jdbc:oracle:thin:@10.78.XXX.XX:1521:XXX"></property>
<property name="user" value="username"></property>
<property name="password" value="password"></property>
</bean>
纯的hibernate工程,配置文件是写在hibernate.cfg.xml中,应该使用上面那种写法,属性写在两个尖括号中间
Spring+Hibernate工程,配置文件写在Spring.xml里面作为bean,应该使用下面这种写法。
分享到:
相关推荐
jdbc connection,
mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法
解决Mysql Error-The user specified as a definer (‘mysql.infoschema’@’localhost’) does not exist
Using the sqljdbc.jar class library, applications must first register the driver as follows: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); When the driver is loaded, you can ...
Using the sqljdbc.jar class library, applications must first register the driver as follows: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); When the driver is loaded, you can ...
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO) ...
conn = DriverManager.getConnection(url, user, password); } catch (Exception e) { System.out.println("连接数据库出现异常" + e.getMessage()); } return conn; } /** * 得到MMSQL连接 * @return */ ...
java project user jdbc
警告: SQL Error: 156, SQLState: S0001 org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.util.JDBCExceptionReporter ...严重: 关键字 'user' 附近有语法错误。 的解决方案。
A bank loan type project that lets the user see by answering a few simple questions if the applicant is eligible for a bank loan or if the applicant would be a risk factor.
数据库信息 driver=com.mysql.cj.jdbc.Driver jdbcUrl=jdbc:mysql://192.168.8.136:3306/jdbc user=root password=root
The games industry needs to make the user experience of its development tools a priority. This book shows how to improve the user experience of game tools and presents specific examples of tools ...
今天小编就为大家分享一篇关于Mysql:The user specified as a definer ('xxx@'%') does not exist的解决方案,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
今天项目优化过程中,mysql有个问题The user specified as a definer (‘wx_root’@’%’) does not exist 查了一下,意思是执行sql无权限。 看了下数据库用户是quoters 而sql没有所属权。那就找原因了。发现sql执行...
Connection conn= DriverManager.getConnection(url,user,password); 2、DB2数据库 Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); String url="jdbc:db2://localhost:5000/sample"; //...
Connection conn= DriverManager.getConnection(url,user,password); 1、SQL Server2005/2008数据库 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); String url="jdbc:sqlserver:...
1、JDBC(Java Database Connection):java连接数据库统一接口API,底层主要通过直接的JDBC驱动和 JDBC-ODBC桥驱动实现与数据库的连接。 1>.JDBC驱动程序类型: <1>.JDBC-ODBC桥加ODBC驱动程序:需要ODBC驱动,适合...
Adapter for JDBC User Guide
Multiple-input multiple-...coding to overcome the interference a user sees from signals intended for other users. We conclude by describing future areas of research in multi-user MIMO communications.
public Connection getCon() throws ClassNotFoundException, SQLException { ... con = DriverManager.getConnection(url,user,password); System.out.println("数据库连接成功!!"); return con; }