hibernate中使用jdbc连接数据库的问题
在应用中我使用了jdbc的方法连接数据库进行查询
Class.forName( "oracle.jdbc.driver.OracleDriver ");
String urlttt= "jdbc:oracle:thin:@127.0.0.1:1521:test ";
String userttt= "mip_hbcgy ";
String pwdttt= "jhcomn ";
Connection conn=DriverManager.getConnection(urlttt,userttt,pwdttt);
有时候页面是正常的,但有使用出错
出现的错误提示是:
Pre-bound JDBC Connection found - HibernateTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single HibernateTransactionManager for all transactions on a single DataSource, no matter whether Hibernate or JDBC access.
------解决方案--------------------用了Hibernate 连接池,为啥还要用JDBC呢
------解决方案--------------------数据库连接要用hibernate提供的方法:
Session session = getSession();
Connection connection = session.connection();
数据查询可以用JDBC的方法:
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( "select sum(decimal(conitem2,10,2)) as aa ,comid from UBL_PROCONTENT where proid= "+proid+ " group by comid ");
------解决方案--------------------好象是你下面的操作没有事务控制