List of usage examples for org.springframework.jdbc.support.rowset SqlRowSet getString
String getString(String columnLabel) throws InvalidResultSetAccessException;
From source file:com.esa.infocontrol.data.jdbc.BaseDataJDBC.java
public static DataArrayWrapper getList(DataSource dataSource, String query, MapSqlParameterSource params) { LOG.debug("QUERY: {}", query); if (params != null) { LOG.debug("\tPARAMETERS: {}", params.getValues().toString()); }/*ww w .j av a 2 s.c o m*/ NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); SqlRowSet rs = jdbcTemplate.queryForRowSet(query, params); SqlRowSetMetaData md = rs.getMetaData(); LOG.debug("\tCOLUMNS: {}", Arrays.toString(md.getColumnNames())); List<DataRow> dataList = new ArrayList<>(); ColumnMetaData[] columnMetaData = new ColumnMetaData[md.getColumnCount()]; for (int i = 1; i <= md.getColumnCount(); ++i) { columnMetaData[i - 1] = new ColumnMetaData(md.getColumnLabel(i), md.getColumnType(i)); } while (rs.next()) { DataRow row = new DataRow(md.getColumnCount()); for (int i = 1; i <= md.getColumnCount(); ++i) { row.add(rs.getString(i)); } dataList.add(row); } return new DataArrayWrapper(dataList, columnMetaData); }
From source file:org.restsql.core.impl.mysql.MySqlSqlResourceMetaData.java
/** * Sets sequence metadata for a column with the columns query result set. * The extra column value will contain the string auto_increment if this is * a sequence./*from w ww . j a v a 2 s .com*/ * * @throws SQLException * when a database error occurs */ @Override protected void setSequenceMetaData(ColumnMetaDataImpl column, SqlRowSet resultSet) { final String extra = resultSet.getString(3); if (extra != null && extra.equals("auto_increment")) { column.setSequence(true); column.setSequenceName(column.getTableName()); } }
From source file:org.restsql.core.impl.postgresql.PostgreSqlSqlResourceMetaData.java
/** * Sets sequence metadata for a column with the columns query result set. * The column_default column will contain a string in the format * nextval('sequence-name'::regclass), where sequence-name is the sequence * name./*from w ww . j a v a2s .c om*/ * * @throws SQLException * when a database error occurs */ @Override protected void setSequenceMetaData(ColumnMetaDataImpl column, SqlRowSet resultSet) { final String columnDefault = resultSet.getString(3); if (columnDefault != null && columnDefault.startsWith("nextval")) { column.setSequence(true); column.setSequenceName(columnDefault.substring(9, columnDefault.indexOf('\'', 10))); } }
From source file:transaction.script.ClearQuestTrScript.java
/** * * @param projectName/*from w ww .j a v a 2 s . co m*/ * @return * @throws SQLException */ public HashMap<String, String> getLastBuildSQLDefChanges(String projectName) throws SQLException { Checker.checkStringForEmpty("project name", projectName, false); String query = dcQueryTemplate.substitute("project", projectName); JdbcTemplate cqTemplate = JdbcTemplateFactory.getClearQuestDBTemplate(); HashMap<String, String> sqlMap = new HashMap<String, String>(); SqlRowSet set = cqTemplate.queryForRowSet(query); while (set.next()) { String dcHeadline = set.getString(HEADLINE); if (dcHeadline.contains("sql")) { sqlMap.put(set.getString(DCNUMBER), dcHeadline); } } return sqlMap; }
From source file:transaction.script.ClearQuestTrScript.java
/** * * @param projectName//from ww w .ja va2s. c om * @return * @throws SQLException */ public HashMap<String, String> getLastBuildDQLDefChanges(String projectName) throws SQLException { Checker.checkStringForEmpty("project name", projectName, false); String query = dcQueryTemplate.substitute("project", projectName); JdbcTemplate cqTemplate = JdbcTemplateFactory.getClearQuestDBTemplate(); HashMap<String, String> dqlmap = new HashMap<String, String>(); SqlRowSet set = cqTemplate.queryForRowSet(query); while (set.next()) { String dcHeadline = set.getString(HEADLINE); if (dcHeadline.contains("dql")) { dqlmap.put(set.getString(DCNUMBER), dcHeadline); } } return dqlmap; }
From source file:com.jaxio.celerio.configuration.database.mysql.MySqlEnumExtractorTest.java
@Test @Ignore/*from ww w.j a v a 2 s . c o m*/ public void film() { SqlRowSet queryForRowSet = jdbcTemplate().queryForRowSet("show columns from film where type like 'enum%'"); while (queryForRowSet.next()) { String field = queryForRowSet.getString("Field"); String type = queryForRowSet.getString("Type"); MysqlEnumValuesExtractor mysqlEnumValuesExtractor = new MysqlEnumValuesExtractor(); System.out.println("Extracting values from " + field + "." + type); for (String a : mysqlEnumValuesExtractor.extract(type)) { System.out.println(a); } } }
From source file:CRM.repository.InteractionsDAO.java
public Map<Integer, String> getClientsMap() { Map<Integer, String> clients = new LinkedHashMap<Integer, String>(); String sql = "SELECT client_id, first_name,last_name FROM clients"; SqlRowSet srs = template.queryForRowSet(sql); while (srs.next()) { clients.put(srs.getInt("client_id"), srs.getString("first_name") + " " + srs.getString("last_name")); }/*from w w w. j a v a 2 s. co m*/ return clients; }
From source file:repository.InteractionsDAO.java
public Map<Integer, String> getClientInteractMap() { Map<Integer, String> Clients = new LinkedHashMap<Integer, String>(); String sql = "SELECT id, firstname, lastname FROM clients ORDER BY firstname"; SqlRowSet rs = template.queryForRowSet(sql); while (rs.next()) { Clients.put(rs.getInt(1), rs.getString(2) + " " + rs.getString(3)); }//from w w w. j a v a 2s .c o m return Clients; }
From source file:mylife.respository.interactionsDAO.java
/** * * @return//from w w w . j a v a 2 s . c o m */ public Map<Integer, String> getclient1Map() { Map<Integer, String> client1 = new LinkedHashMap<Integer, String>(); String sql = "SELECT idclient1, firstname FROM client1 ORDER BY firstname"; SqlRowSet rs = template.queryForRowSet(sql); while (rs.next()) { client1.put(rs.getInt(1), rs.getString(2)); } return client1; }
From source file:ru.org.linux.group.TopicsListItem.java
public TopicsListItem(User author, SqlRowSet rs, int messagesInPage, ImmutableList<String> tags) { this.author = author; this.tags = tags; subj = StringUtil.makeTitle(rs.getString("subj")); Timestamp lastmod = rs.getTimestamp("lastmod"); if (lastmod == null) { this.lastmod = new Timestamp(0); } else {//w w w. j a va 2 s . c o m this.lastmod = lastmod; } msgid = rs.getInt("msgid"); deleted = rs.getBoolean("deleted"); stat1 = rs.getInt("stat1"); stat3 = rs.getInt("stat3"); stat4 = rs.getInt("stat4"); sticky = rs.getBoolean("sticky"); resolved = rs.getBoolean("resolved"); pages = Topic.getPageCount(stat1, messagesInPage); }