日期:2014-05-20  浏览次数:20556 次

tomcat没访问几次就歇菜了~
//创建session
public static Session getSession(){
Configuration config = new Configuration().configure();
SessionFactory factory = config.buildSessionFactory();
Session session = factory.openSession();
return session;  
}
//其中一个dao
//增加图片
public boolean addImg(Img img){
Session session = DBUtil.getSession();
Transaction t = session.beginTransaction();
boolean falg = false;
try{
if(img!=null){
falg= true;
session.save(img);
}
t.commit();
}catch(Exception e){
t.rollback();
}finally{
session.close();
}
return falg;
}
//hibernate配置
<hibernate-configuration>
  <session-factory>
  <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
  <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=skynet</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
  <!-- <property name="hibernate.show_sql">true</property> -->
  <mapping resource="com/xml/img.hbm.xml"/>
  </session-factory>
</hibernate-configuration>
没有连接池
tomcat也没有设置任何东西,应该我的程序有问题··谁能帮忙看看,顺便解决下,谢谢~~
··还有数据库如果用oracle,当V$session这张表 达到150左右就会报错··是什么原因呢

------解决方案--------------------
session有个disconnect方法吧
------解决方案--------------------
报的是数据库连接池达到最大数了吧。你应该加一个数据库连接池。分区进行设置。
<property name="idleConnectionTestPeriod" value="15" />
<property name="idleMaxAge" value="10" />
<property name="maxConnectionsPerPartition" value="10" />
<property name="minConnectionsPerPartition" value="5" />
<property name="partitionCount" value="3" />
<property name="acquireIncrement" value="5" />
<property name="statementsCacheSize" value="100" />
<property name="releaseHelperThreads" value="3" />