List of usage examples for java.sql SQLException fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.RandomSubtypeHierarchyProviderImpl.java
/** * Initialise statements./*w w w .j av a 2 s.c o m*/ */ @Override public void initialiseStatements() { try { super.initialiseStatements(); getDescendantsStatement = getConnection().prepareStatement( "" + "SELECT " + getSubTypeColumnName() + " FROM " + getSchemaName() + "." + getTcTableName() + " WHERE " + getSuperTypeColumnName() + " = ? " + " ORDER BY RAND() LIMIT ?"); } catch (SQLException e) { logger.warn("Nested exception is : " + e.fillInStackTrace().getMessage()); } }
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.RandomSubtypeHierarchyProviderImpl.java
/** * This method should return a set of random descendants. Note the SQL used is MySQL specific * @param parentConceptId the parent concept for which subtypes need to be returned * @param subsetSize the max number of subtypes to be returned * @return//from www . j a va 2 s.com */ public Collection<String> getRandomSetOfSubTypes(String parentConceptId, int subsetSize) { Set<String> descendantIds = new HashSet<String>(); if (parentConceptId != null && !"".equalsIgnoreCase(parentConceptId)) { // get concept id and set parameter try { getDescendantsStatement.setString(1, parentConceptId); getDescendantsStatement.setInt(2, subsetSize); ResultSet rs = getDescendantsStatement.executeQuery(); while (rs.next()) { String descendantId = rs.getString(1); descendantIds.add(descendantId); } } catch (SQLException e) { logger.warn("Nested exception is : " + e.fillInStackTrace()); } return descendantIds; } else { throw new IllegalArgumentException(NULL_ARG_MSG + parentConceptId); } }
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.TransitiveClosureTableBasedHierarchyProvider.java
/** * Initialise statements.//from www .j a va 2 s . c o m */ @Override public void initialiseStatements() { try { super.initialiseStatements(); getAncestorsStatement = getConnection().prepareStatement("" + "SELECT " + superTypeColumnName + " FROM " + getSchemaName() + "." + tcTableName + " WHERE " + subTypeColumnName + " = ?"); getDescendantsStatement = getConnection().prepareStatement("" + "SELECT " + subTypeColumnName + " FROM " + getSchemaName() + "." + tcTableName + " WHERE " + superTypeColumnName + " = ?"); } catch (SQLException e) { logger.warn("Nested exception is : " + e.fillInStackTrace().getMessage()); } }
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.TransitiveClosureTableBasedHierarchyProvider.java
public Set<String> getDescendants(String conceptId) { Set<String> descendantIds = new HashSet<String>(); if (conceptId != null && !"".equalsIgnoreCase(conceptId)) { // get concept id and set parameter try {/*from w w w . j a va2 s . c om*/ getDescendantsStatement.setString(1, conceptId); ResultSet rs = getDescendantsStatement.executeQuery(); while (rs.next()) { String descendantId = rs.getString(1); descendantIds.add(descendantId); } } catch (SQLException e) { logger.warn("Nested exception is : " + e.fillInStackTrace()); } return descendantIds; } else { throw new IllegalArgumentException(NULL_ARG_MSG + conceptId); } }
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.TransitiveClosureTableBasedHierarchyProvider.java
public Set<String> getAncestors(String conceptId) { Set<String> ancestorIds = new HashSet<String>(); if (conceptId != null && !"".equalsIgnoreCase(conceptId)) { // get concept id and set parameter try {/* w w w . j ava 2s .c om*/ getAncestorsStatement.setString(1, conceptId); ResultSet rs = getAncestorsStatement.executeQuery(); while (rs.next()) { String ancestorID = rs.getString(1); ancestorIds.add(ancestorID); } } catch (SQLException e) { logger.warn("Nested exception is : " + e.fillInStackTrace()); } return ancestorIds; } else { throw new IllegalArgumentException(NULL_ARG_MSG + conceptId); } }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.queryresultspanel.actions.PublishQueryResultsFromResultSetTask.java
/** * Do in background.//from ww w . j a v a 2s. c o m * * @return the void * * @throws Exception the exception */ @SuppressWarnings("unchecked") @Override protected Void doInBackground() throws Exception { // loop through result set and publish all columns if (!isCancelled()) { if (resultSet != null) { try { int colNum = resultSet.getMetaData().getColumnCount(); while (resultSet.next()) { List<Object> localList = new ArrayList<Object>(); for (int i = 0; i < colNum; i++) { // add to local list localList.add(resultSet.getObject(i + 1)); } // publish list publish(localList); } } catch (SQLException e) { logger.warn(e.fillInStackTrace().getMessage()); } } else { logger.warn("Null result set passed. Please check you've executed a valid query."); } } return null; }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.queryresultspanel.model.table.ResultSetTableModel.java
/** * Sets the column names from result set. * //from w w w .ja va2s. c o m * @param resultSet the new column names from result set */ public void setColumnNamesFromResultSet(ResultSet resultSet) { try { ResultSetMetaData metaData = resultSet.getMetaData(); int colCount = metaData.getColumnCount(); // reset column names array columnNames = new String[colCount]; for (int i = 0; i < colCount; i++) { String colName = metaData.getColumnName(i + 1); // convert colname to human readable form colName = convertDBColumnNameToJTableColumnName(colName); columnNames[i] = colName; } fireTableStructureChanged(); } catch (SQLException e) { logger.warn("Error generating table structure from result set." + "\nNested exception is : " + e.fillInStackTrace().getMessage()); } }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.queryresultspanel.model.table.ResultSetTableModel.java
/** * Populate model./*from w w w .j a v a 2 s .c o m*/ * * @param resultSet the result set */ public void populateModel(ResultSet resultSet) { if (resultSet != null) { // get column names from result set setColumnNamesFromResultSet(resultSet); // clear data dataList.clear(); try { while (resultSet.next()) { List<Object> localList = new ArrayList<Object>(); for (int i = 0; i < columnNames.length; i++) { // add to local list localList.add(resultSet.getObject(i + 1)); } // add local list to data list dataList.add(localList); } } catch (SQLException e) { logger.warn(e.fillInStackTrace()); } // notify listeners fireTableStructureChanged(); } }
From source file:uk.nhs.cfh.dsp.srth.query.transform.sql.impl.AbstractSQLQueryEngineService.java
/** * Drop table or view if exists.// w w w. j a v a2 s . com * * @param tableName the table name * @param st the st * @param collection the collection */ protected void dropTableOrViewIfExists(String tableName, Statement st, QueryStatisticsCollection collection) { try { st.execute("DROP TABLE IF EXISTS " + tableName); st.execute("DROP VIEW IF EXISTS " + tableName); collection.getCommentedSteps().add("Dropped table/view with statement : "); collection.getCommentedSteps().add("DROP TABLE IF EXISTS " + tableName); collection.getCommentedSteps().add("DROP VIEW IF EXISTS " + tableName); collection.getSqlSteps().add("DROP TABLE IF EXISTS " + tableName); collection.getSqlSteps().add("DROP VIEW IF EXISTS " + tableName); } catch (SQLException e) { logger.warn(e.fillInStackTrace()); } }
From source file:uk.nhs.cfh.dsp.srth.query.transform.sql.impl.AbstractSQLQueryEngineService.java
/** * Creates the table./*from ww w.j a va2 s .c o m*/ * * @param tableName the table name * @param tableCreationString the table creation string * @param addColsToColMap the add cols to col map * @param indexColumns the index columns * @param collection the collection */ protected void createTable(String tableName, String tableCreationString, boolean addColsToColMap, String[] indexColumns, QueryStatisticsCollection collection) { if (logger.isDebugEnabled()) { logger.debug("Value of tableCreateString : " + tableCreationString); } if (addColsToColMap) { // add additional column names for future reference List<String> list = new ArrayList<String>(); list.add("CONCEPT_ID"); list.add("ENTRY_TIME"); list.add("FREE_TEXT_ENTRY"); tableColumnsMap.put(tableName, list); } // execute statements try { Statement st = connection.createStatement(); // drop table if it already exists dropTableOrViewIfExists(tableName, st, collection); st.execute(tableCreationString); collection.getCommentedSteps().add("Creating table " + tableName + " using statement : "); collection.getCommentedSteps().add(tableCreationString); collection.getSqlSteps().add(tableCreationString); // add indices for (String colName : indexColumns) { addIndexOnColumnOnTable(tableName, st, colName, collection); } // close statement st.close(); } catch (SQLException e) { logger.warn(e.fillInStackTrace()); } }