解决方案 »
- jsp页面怎么获得保留空格的的字符串
- java nio 客户端异常关闭问题
- java web开发中怎么实现这个功能?
- 在spring中已经有了一个连接oracle数据库的配置,在不改变spring配置的情况下,怎么在代码中实现访问另一个oracle数据库
- 我的ECLIPSE环境出现了以下这个问题,请各位帮帮忙,在线等!
- String对象的replaceAll怎么用?我照写以下的函数,在编译时没出错,但执行时"java.lang.NoSuchMethodError: java.lang.String: method repl
- 急,怎样把日期带时间存入ORACLE中的DATE字段
- SSH2 服务器的保留值,不清空的问题
- 我找不到错误呀!!!代码。
- Linux系统中tomcat环境如何设置jvm参数
- 急求jsp或java显示当前位置导航!!!谢谢!!!
- 这样的actionform怎么写?
<property name="driverClass" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
<property name="jdbcUrl" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=webpro;"/>
<property name="user" value="sa"/>
<property name="password" value="sa"/>
<property name="initialPoolSize" value="3"/>
<property name="maxIdleTime" value="3600"/>
<property name="minPoolSize" value="2"/>
<property name="maxPoolSize" value="200"/>
<property name="idleConnectionTestPeriod" value="30000"/>
<property name="acquireIncrement" value="20"/>
<property name="acquireRetryAttempts" value="30"/>
<property name="acquireRetryDelay" value="1000"/>
<property name="autoCommitOnClose" value="false"/>
<property name="automaticTestTable" value="ybtabletest"/>
<property name="breakAfterAcquireFailure" value="false"/>
<property name="checkoutTimeout" value="30000"/>
<property name="maxStatements" value="10000"/>
<property name="maxStatementsPerConnection" value="0"/>
<property name="numHelperThreads" value="10"/>
<property name="propertyCycle" value="100"/>
<property name="testConnectionOnCheckout" value="false"/>
<property name="testConnectionOnCheckin" value="false"/>
</bean>
public List find(String HQL) {
Session s=HibernateSessionFactory.getSession();
BasicDataMenber ss=new BasicDataMenber();//实体bean
Query q=s.createQuery(HQL);
s.evict(ss);
return q.list();
}
这个工厂都关了还玩什么,工厂是只有一个而session是每次都创建的.
这样写可可以吗?会不会耗费连接资源。?
public List ObjectHqlSelect(String hql) {
// TODO Auto-generated method stub
Session s=this.getSession();
Query query=s.createQuery(hql);
List list=query.list();
s.close();
return list;
}
你关闭了会话工厂,那如何产生会话?
Session session = null;
public List ObjectHqlSelect(String hql) {
session = HibernateUtil.getSessionFactory().getCurrentSession();
Query query=session.createQuery(hql);
List list=query.list();
session.close();
return list;
}
Class HibernateUtil{
private static SessionFactory sessionFactroy;
static{
sessionFactroy = new Configuration().buildSessionFactory();
}
public static SessionFactory getSessionFactory(){
return sessionFactroy ;
}
}
Class HibernateUtil{
private static SessionFactory sessionFactroy;
static{
sessionFactroy = new Configuration().buildSessionFactory();
}
public static SessionFactory getSessionFactory(){
return sessionFactroy ;
}
}
改成try{
sessionFactory = new Configuration().configure().buildSessionFactory();
}catch(Exception e){
e.printStackTrace();
}手写错了。呵呵