protected TableStandardName lookupTableStandardName(String standardName) { TableStandardName name = super.lookupTableStandardName(standardName); if (name == null) { SessionHelper helper = new SessionHelper(mSessions); try { Session session = helper.beginTransaction(); List results = session.find( "SELECT name" + " FROM TableStandardName name" + " WHERE name.name = ?", standardName, Hibernate.STRING); if (results.size() == 1) { name = (TableStandardName) results.get(1); } } catch (HibernateException e) { helper.rollback(System.err); } finally { helper.close(System.err); } if (name != null) { mTableStandardNames.put(standardName, name); } } return name; }
private void logDatabaseInfo() throws ServletException { SessionHelper helper = RetsServer.createHelper(); try { Session session = helper.beginSession(); Connection connection = session.connection(); DatabaseMetaData metaData = connection.getMetaData(); LOGGER.info( "JDBC Driver info: " + metaData.getDriverName() + " version " + metaData.getDriverVersion()); LOGGER.info( "JDBC DB info: " + metaData.getDatabaseProductName() + " version " + metaData.getDatabaseProductVersion()); } catch (SQLException e) { throw new ServletException("Caught", e); } catch (HibernateException e) { throw new ServletException("Caught", e); } finally { try { helper.close(); } catch (HibernateException e) { throw new ServletException(e); } } }
public void close(PrintStream stream) { try { close(); } catch (RetsServerException e) { mSession = null; e.printStackTrace(stream); } }
public void close(Logger log) { try { close(); } catch (RetsServerException e) { mSession = null; log.warn("Exception", e); } }
private MSystem findSystemFromHibernate() { SessionHelper helper = new SessionHelper(mSessions); MSystem system = null; try { Session session = helper.beginTransaction(); List results = new ArrayList(); Iterator iterator = session.iterate("from MSystem"); while (iterator.hasNext()) { results.add(iterator.next()); } if (results.size() == 1) { system = (MSystem) results.get(0); } } catch (HibernateException e) { LOG.warn("Caught", e); helper.rollback(LOG); } finally { helper.close(LOG); } return system; }