Java MySQL服务器很好。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。嗯。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。 private static SessionFactory factory = null; p
Java MySQL服务器很好。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。嗯。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。 private static SessionFactory factory = null; p,java,mysql,hibernate,Java,Mysql,Hibernate,MySQL服务器很好。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。嗯。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。 private static SessionFactory factory = null; private DeploymentInfo deploymentInfo = null; private CheckLockStatusService checkLockStatusService = new CheckLockStatusS
MySQL服务器很好。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。嗯。。。第一个是真的像一个工作周围。。。这不是避免此类问题的最佳做法。
private static SessionFactory factory = null;
private DeploymentInfo deploymentInfo = null;
private CheckLockStatusService checkLockStatusService = new CheckLockStatusService();
/**
* Constructor
*/
public DeploymentInfoDAO() {
}
/**
* Constructor
*
* @param deploymentInfo
*/
public DeploymentInfoDAO(DeploymentInfo deploymentInfo) {
this.deploymentInfo = deploymentInfo;
// this.checkLockStatusService = new CheckLockStatusService();
}
/**
* SELECT * FROM servicedashboard and converts the results into a list of
* ServiceRow
*
* @return
*/
public List<ServiceRow> getServiceRows() {
List<ServiceRow> serviceRows = new ArrayList<ServiceRow>();
if (factory == null){
try {
factory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);
}
}
// mysql select test
Session session = factory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
List<DeploymentInfo> deploymentInfos = session
.createQuery(
"FROM com.test.hibernate.pojo.DeploymentInfo")
.list();
for (Iterator<DeploymentInfo> iterator = deploymentInfos.iterator(); iterator
.hasNext();) {
DeploymentInfo deploymentInfo = iterator.next();
ServiceRow serviceRow = this
.convertToServiceRow(deploymentInfo);
serviceRows.add(serviceRow);
}
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
return serviceRows;
}
}
jdbc:mysql://<host>:<port>/<db>?autoReconnect=true