本文整理汇总了Java中org.springframework.jdbc.support.rowset.SqlRowSetMetaData类的典型用法代码示例。如果您正苦于以下问题:Java SqlRowSetMetaData类的具体用法?Java SqlRowSetMetaData怎么用?Java SqlRowSetMetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlRowSetMetaData类属于org.springframework.jdbc.support.rowset包,在下文中一共展示了SqlRowSetMetaData类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dump
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
private static void dump(String sql) {
logger.fine("\n" + sql);
SqlRowSet rs = dao.getJdbcTemplate().queryForRowSet(sql);
try {
SqlRowSetMetaData rsmd = rs.getMetaData();
int c = rsmd.getColumnCount();
StringBuffer buff = new StringBuffer();
for (int i = 1; i <= c; i++) {
buff.append(rsmd.getColumnLabel(i));
buff.append(i == c ? "\n" : "\t");
}
logger.fine(buff.toString());
buff.delete(0, buff.length());
while (rs.next()) {
for (int i = 1; i <= c; i++) {
buff.append(rs.getObject(i));
buff.append(i == c ? "\n" : "\t");
}
logger.fine(buff.toString());
buff.delete(0, buff.length());
}
logger.fine("================\n\n");
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:intuit,项目名称:Tank,代码行数:27,代码来源:JdbcMessageDAOTest.java
示例2: addHeaders
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
@Override
public Grid addHeaders( SqlRowSet rs )
{
SqlRowSetMetaData rsmd = rs.getMetaData();
int columnNo = rsmd.getColumnCount();
for ( int i = 1; i <= columnNo; i++ )
{
addHeader( new GridHeader( rsmd.getColumnLabel( i ), false, false ) );
}
return this;
}
开发者ID:dhis2,项目名称:dhis2-core,代码行数:15,代码来源:ListGrid.java
示例3: addHeaders
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
@Override
public Grid addHeaders( SqlRowSet rs )
{
SqlRowSetMetaData rsmd = rs.getMetaData();
int columnNo = rsmd.getColumnCount();
for ( int i = 1; i <= columnNo; i++ )
{
addHeader( new GridHeader( rsmd.getColumnLabel( i ), false, false ) );
}
return this;
}
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:15,代码来源:ListGrid.java
示例4: CreateEntity
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
public void CreateEntity(String tablename,String packagename,JdbcTemplate jdbcTemplate) throws SQLException {
_tablename=tablename;
_packagename=packagename;
String strsql = "select * from " + tablename;
try {
SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(strsql);
SqlRowSetMetaData sqlRsmd = sqlRowSet.getMetaData();
int size = sqlRsmd.getColumnCount();
colnames = new String[size];
colTypes = new String[size];
colSizes = new int[size];
for (int i = 0; i < size; i++) {
colnames[i] = sqlRsmd.getColumnName(i + 1);
colTypes[i] = sqlRsmd.getColumnTypeName(i + 1);
if (colTypes[i].equalsIgnoreCase("datetime")) {
f_util = true;
}
if (colTypes[i].equalsIgnoreCase("image")
|| colTypes[i].equalsIgnoreCase("text")) {
f_sql = true;
}
colSizes[i] = sqlRsmd.getColumnDisplaySize(i + 1);
}
String content = parse(colnames, colTypes, colSizes);
try {
FileWriter fw = new FileWriter(initcap(tablename) + ".java");
PrintWriter pw = new PrintWriter(fw);
pw.println(content);
pw.flush();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
} finally {
}
}
开发者ID:liujiarik,项目名称:JdbcTemplateReverseTool,代码行数:38,代码来源:JdbcTemplateGenEntityTool.java
示例5: writeOutput
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
@Override
public OutputResult writeOutput(Output output) {
PersistentStorage<ModelOutput> persistentStorage = storageFactory.getPersistentStorage();
OutputResult result = new OutputResult(output);
String selectSQL = output.makeTempDBSelectStarSQL();
SqlRowSet rowSet = null;
SqlRowSetMetaData metadata = null;
try {
rowSet = storage.getTempJdbcTemplate().queryForRowSet(selectSQL);
metadata = rowSet.getMetaData();
} catch (Exception e) {
throw new RuntimeException("Failure while trying to retrieve the output data set: " + selectSQL);
}
List<ModelOutput> modelOutputEntities = new ArrayList<ModelOutput>();
String modelRunId = UUID.randomUUID().toString();
while (rowSet.next()) {
ModelOutput modelOutput = new ModelOutput();
Map<String, Object> data = new HashMap<String, Object>();
for (String column : metadata.getColumnNames()) {
data.put(column, rowSet.getObject(column));
}
modelOutput.setOutput(data);
modelOutput.setModelRunId(modelRunId);
modelOutputEntities.add(modelOutput);
}
persistentStorage.saveAll(modelOutputEntities);
result.done(modelRunId, modelOutputEntities.size());
return result;
}
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:LearningAnalyticsProcessor,代码行数:37,代码来源:StorageOutputHandler.java
示例6: get
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
@Override
public Map<String, Object> get() {
Map<String, Object> result = Maps.newHashMap();
final SqlRowSetMetaData metadata = rowSet.getMetaData();
for(int i = 1; i <= metadata.getColumnCount(); i++) {
String columnTypeName = metadata.getColumnTypeName(i);
final Object value;
if("array".equalsIgnoreCase(columnTypeName)) {
value = parseJson(rowSet.getString(i), List.class);
} else if("map".equalsIgnoreCase(columnTypeName)
|| "struct".equalsIgnoreCase(columnTypeName)) {
value = parseJson(rowSet.getString(i), Map.class);
} else if("string".equalsIgnoreCase(columnTypeName)) {
value = HiveUtils.unescapeString(rowSet.getString(i));
} else {
value = rowSet.getObject(i);
}
result.put(metadata.getColumnName(i), value);
}
return result;
}
开发者ID:simplymeasured,项目名称:prognosticator,代码行数:28,代码来源:HiveQueryCursorImpl.java
示例7: testGet
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; //导入依赖的package包/类
@Test
public void testGet() {
// build up a result inside the mock, test it.
// column 1 = string, named STR
// column 2 = long, named LNG
// column 3 = Map, named MAP
// column 4 = Array, named LIST
// column 5 = Struct (serialized to a Java Map), named STRUCT
SqlRowSetMetaData metadata = mock(SqlRowSetMetaData.class);
when(metadata.getColumnCount()).thenReturn(5);
when(metadata.getColumnName(1)).thenReturn("STR");
when(metadata.getColumnTypeName(1)).thenReturn("STRING");
when(metadata.getColumnName(2)).thenReturn("LNG");
when(metadata.getColumnTypeName(2)).thenReturn("BIGINT");
when(metadata.getColumnName(3)).thenReturn("MAP");
when(metadata.getColumnTypeName(3)).thenReturn("MAP");
when(metadata.getColumnName(4)).thenReturn("LIST");
when(metadata.getColumnTypeName(4)).thenReturn("ARRAY");
when(metadata.getColumnName(5)).thenReturn("STRUCT");
when(metadata.getColumnTypeName(5)).thenReturn("STRUCT");
when(rowSet.getMetaData()).thenReturn(metadata);
when(rowSet.getString(1)).thenReturn("My string");
when(rowSet.getObject(2)).thenReturn(123L);
when(rowSet.getString(3)).thenReturn("{\"foo\":\"str1\", \"bar\":\"str2\"}");
when(rowSet.getString(4)).thenReturn("[1, 2, 3]");
when(rowSet.getString(5)).thenReturn("{\"struct1\": \"asdf\", \"struct2\": 1234 }");
Map<String, Object> result = cursor.get();
Assert.assertNotNull(result);
Assert.assertFalse(result.isEmpty());
Map<String, Object> expected = new HashMap<String, Object>() {
{
put("STR", "My string");
put("LNG", 123L);
put("MAP", new HashMap<String, String>() {
{
put("foo", "str1");
put("bar", "str2");
}
});
put("LIST", new ArrayList<Integer>() {
{
add(1);
add(2);
add(3);
}
});
put("STRUCT", new HashMap<String, Object>() {
{
put("struct1", "asdf");
put("struct2", 1234);
}
});
}
};
Assert.assertEquals(expected, result);
}
开发者ID:simplymeasured,项目名称:prognosticator,代码行数:71,代码来源:HiveQueryCursorImplTest.java
注:本文中的org.springframework.jdbc.support.rowset.SqlRowSetMetaData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论