List of usage examples for com.liferay.portal.kernel.util InfrastructureUtil getDataSource
public static DataSource getDataSource()
From source file:br.ufpe.cin.da.salada.service.base.MensagemServiceBaseImpl.java
License:Open Source License
/** * Performs an SQL query.// w w w . ja v a2s . c o m * * @param sql the sql query */ protected void runSQL(String sql) throws SystemException { try { DataSource dataSource = InfrastructureUtil.getDataSource(); SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, sql, new int[0]); sqlUpdate.update(); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.bemis.portal.customer.service.base.CustomerProfileLocalServiceBaseImpl.java
License:Open Source License
/** * Performs a SQL query.// ww w . jav a 2 s . c o m * * @param sql the sql query */ protected void runSQL(String sql) { try { DataSource dataSource = InfrastructureUtil.getDataSource(); DB db = DBManagerUtil.getDB(); sql = db.buildSQL(sql); sql = PortalUtil.transformSQL(sql); SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, sql); sqlUpdate.update(); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.cambiahealth.portal.dbcleanup.service.impl.CorruptedLayoutLocalServiceImpl.java
License:Open Source License
protected void doDeleteCorruptedLayouts(long groupId) { DataSource dataSource = InfrastructureUtil.getDataSource(); Connection connection = null; PreparedStatement deleteStatement = null; try {/*from ww w .j a v a 2 s . com*/ connection = dataSource.getConnection(); deleteStatement = connection.prepareStatement(_SQL_DELETE_LAYOUTS_BY_GROUP_ID); deleteStatement.setLong(1, groupId); int deleteCount = deleteStatement.executeUpdate(); if (deleteCount > 0) { _log.info(">>> Deleted " + deleteCount + " corrupted layouts associated with groupId: " + groupId); } } catch (SQLException sqle) { _log.error(">>> Error deleting layouts for groupId: ", sqle); } finally { DbUtil.closeQuietly(connection); DbUtil.closeQuietly(deleteStatement); } }
From source file:com.cambiahealth.portal.dbcleanup.service.impl.GroupUserRelationLocalServiceImpl.java
License:Open Source License
public int getGroupUserRelationsCount(long groupId) throws SystemException { int count = 0; DataSource dataSource = InfrastructureUtil.getDataSource(); Connection connection = null; PreparedStatement countStatement = null; ResultSet resultSet = null;//from w ww .j ava 2 s . c o m try { connection = dataSource.getConnection(); countStatement = connection.prepareStatement(_SQL_COUNT_USERS_GROUPS_BY_GROUP_ID); countStatement.setLong(1, groupId); resultSet = countStatement.executeQuery(); if (resultSet.next()) { count = resultSet.getInt(1); } } catch (SQLException sqle) { _log.error(">>> Error deleting layouts for groupId: ", sqle); } finally { DbUtil.closeQuietly(connection, countStatement, resultSet); } return count; }
From source file:com.liferay.calendar.service.base.CalendarImporterLocalServiceBaseImpl.java
License:Open Source License
/** * Performs a SQL query.//from ww w .j a v a 2s.c o m * * @param sql the sql query */ protected void runSQL(String sql) { try { DataSource dataSource = InfrastructureUtil.getDataSource(); DB db = DBFactoryUtil.getDB(); sql = db.buildSQL(sql); sql = PortalUtil.transformSQL(sql); SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, sql, new int[0]); sqlUpdate.update(); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.liferay.customsql.user.UserFinder.java
License:Open Source License
public UserFinder() { setDataSource(InfrastructureUtil.getDataSource()); setSessionFactory((SessionFactory) PortalBeanLocatorUtil.locate("liferaySessionFactory")); ClassLoader classLoader = PortalClassLoaderUtil.getClassLoader(); try {// w ww. j a v a 2 s .c om _userImplClass = classLoader.loadClass("com.liferay.portal.model.impl.UserImpl"); } catch (ClassNotFoundException cnfe) { throw new RuntimeException(cnfe.getMessage(), cnfe); } }
From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java
License:Open Source License
private List<String> getRegionandTypeList(String name) { Connection conn = null;/*from w ww . j ava 2s . c o m*/ DataSource source = InfrastructureUtil.getDataSource(); List<String> regionTypeList = new ArrayList<String>(); try { Class.forName(PropsUtil.get("jdbc.default.driverClassName")); conn = source.getConnection(); String query = "select superType,superRegion from stoxx_indexdb where symbol=?"; PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setString(1, name.toUpperCase()); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { String superType = rs.getString("superType"); String superRegion = rs.getString("superRegion"); log.info("superType is : " + superType + " superRegion is" + superRegion); regionTypeList.add(superType); regionTypeList.add(superRegion); } } catch (SQLException e) { log.info("SQLException", e); } catch (ClassNotFoundException e) { log.info(e.getMessage(), e); } finally { try { if (null != conn) { conn.close(); } } catch (SQLException e) { log.error(e.getMessage(), e); } } regionTypeList.removeAll(Collections.singleton(null)); return regionTypeList; }