本文整理匯總了Java中org.springframework.jdbc.core.ResultSetExtractor類的典型用法代碼示例。如果您正苦於以下問題:Java ResultSetExtractor類的具體用法?Java ResultSetExtractor怎麽用?Java ResultSetExtractor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResultSetExtractor類屬於org.springframework.jdbc.core包,在下文中一共展示了ResultSetExtractor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: viewUserNames
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public String viewUserNames() {
return jdbcTemplate
.query(
"select loginid from USERLOGIN where logintype='user' or logintype='owner' order by userid",
new ResultSetExtractor<String>() {
String s = "";
public String extractData(ResultSet rs)
throws SQLException, DataAccessException {
while (rs.next()) {
s = s + rs.getString(1) + ",";
}
return s;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:18,代碼來源:RegistrationDAO.java
示例2: fetchList
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
/**
* 取分頁
*
* @param jt
* jdbcTemplate
* @param sqlFetchRows
* 查詢數據的sql
* @param args
* 查詢參數
* @param size
* 大小
* @param rowMapper
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<E> fetchList(final JdbcTemplate jt, final String sqlFetchRows,
final Object args[], final int size, final ParameterizedRowMapper<E> rowMapper) {
if (size == 0) {
return null;
}
final Page<E> page = new Page<E>();
// TODO 在數據量很大時, limit效率很低
final String selectSQL = sqlFetchRows + " limit " + size;
jt.query(selectSQL, args, new ResultSetExtractor() {
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
final List<E> pageItems = page.getPageItems();
int currentRow = 0;
while (rs.next()) {
pageItems.add(rowMapper.mapRow(rs, currentRow++));
}
return pageItems;
}
});
return page.getPageItems();
}
示例3: testResultSetExtractorPrototypeInstantiation
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
@Test
public void testResultSetExtractorPrototypeInstantiation() {
Set<String> tableAliases = new HashSet<>();
tableAliases.add("wayseg");
tableAliases.add("xit");
ResultSetExtractor<? extends IBaseSegment> rsExtractor1 = resultSetExtractorFactory.getResultSetExtractor(tableAliases);
ResultSetExtractor<? extends IBaseSegment> rsExtractor2 = resultSetExtractorFactory.getResultSetExtractor(tableAliases);
try {
rsExtractor1.extractData(null);
rsExtractor2.extractData(null);
} catch (DataAccessException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Assert.assertNotEquals(rsExtractor1, rsExtractor2);
}
示例4: executeSingleResultQuery
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
private Object executeSingleResultQuery(String query, Map<?, ?> params)
{
return jdbcTemplate.query(query, params, new ResultSetExtractor()
{
@Override
public Object extractData(ResultSet rs) throws SQLException, DataAccessException
{
Object data = null;
if( rs.next() )
{
data = rs.getObject(1);
// Sanity check - ensure only a single result
if( rs.next() )
{
throw new IncorrectResultSizeDataAccessException(1);
}
}
return data;
}
});
}
示例5: viewFileName
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public String viewFileName() {
return jdbcTemplate.query(
"select * from CLOUDFILEDATA order by FILEDATAID",
new ResultSetExtractor<String>() {
String s = "";
public String extractData(ResultSet rs)
throws SQLException, DataAccessException {
while (rs.next()) {
s = s + rs.getString(5) + ",";
}
return s;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:17,代碼來源:RegistrationDAO.java
示例6: viewFileKey
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public String viewFileKey(String filename) {
return jdbcTemplate.query(
"select PUBLICKEY from CLOUDFILEDATA where filename='"
+ filename.trim() + "'",
new ResultSetExtractor<String>() {
String s = "";
public String extractData(ResultSet rs)
throws SQLException, DataAccessException {
while (rs.next()) {
s = s + rs.getString(1) + ",";
}
return s;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:18,代碼來源:RegistrationDAO.java
示例7: viewFileSignature
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public String viewFileSignature(String groupname) {
return jdbcTemplate.query(
"select GROUPSIGNATURE from GROUPS where GROUPNAME='"
+ groupname.trim() + "'",
new ResultSetExtractor<String>() {
String s = "";
public String extractData(ResultSet rs)
throws SQLException, DataAccessException {
while (rs.next()) {
s = s + rs.getString(1) + ",";
}
return s;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:18,代碼來源:RegistrationDAO.java
示例8: viewGroupname
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Users viewGroupname(final Users users) {
return jdbcTemplate
.query(
"select userid,(select (select groupname from groups where groupid=GROUPUSERS.groupid) from GROUPUSERS where userid=userlogin.userid) from userlogin where loginid='"
+ users.getLoginid() + "'",
new ResultSetExtractor<Users>() {
public Users extractData(ResultSet rs)
throws SQLException, DataAccessException {
if (rs.next()) {
users.setGroupname(rs.getString(2));
users.setUserid(rs.getInt(1));
}
return users;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:20,代碼來源:RegistrationDAO.java
示例9: managerLoginCheck
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Users managerLoginCheck(Users users) {
return jdbcTemplate.query("select * from userlogin where loginid='"
+ users.getLoginid() + "' and password='" + users.getPassword()
+ "' and logintype='manager'", new ResultSetExtractor<Users>() {
public Users extractData(ResultSet rs) throws SQLException,
DataAccessException {
Users user = new Users();
if (rs.next()) {
user.setUserid(rs.getInt(1));
user.setLoginid(rs.getString(2));
user.setLogintype(rs.getString(3));
}
return user;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:19,代碼來源:RegistrationDAO.java
示例10: viewUserLoginMetaData
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Object[] viewUserLoginMetaData() {
return jdbcTemplate.query("select * from userlogin",
new ResultSetExtractor<Object[]>() {
public Object[] extractData(ResultSet rs)
throws SQLException, DataAccessException {
ResultSetMetaData resultSetMetaData = rs.getMetaData();
String tablemetadata[] = new String[] {
resultSetMetaData.getColumnName(1),
resultSetMetaData.getColumnName(2),
resultSetMetaData.getColumnName(4),
resultSetMetaData.getColumnName(5),
resultSetMetaData.getColumnName(6),
"GroupName", };
return tablemetadata;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:19,代碼來源:RegistrationDAO.java
示例11: viewCloudMetaData
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Object[] viewCloudMetaData() {
return jdbcTemplate.query(
"select * from CLOUDFILEDATA order by FILEDATAID",
new ResultSetExtractor<Object[]>() {
public Object[] extractData(ResultSet rs)
throws SQLException, DataAccessException {
ResultSetMetaData resultSetMetaData = rs.getMetaData();
String tablemetadata[] = new String[] {
resultSetMetaData.getColumnName(1),
resultSetMetaData.getColumnName(2),
resultSetMetaData.getColumnName(3),
resultSetMetaData.getColumnName(4),
resultSetMetaData.getColumnName(5),
resultSetMetaData.getColumnName(6),
resultSetMetaData.getColumnName(9),
resultSetMetaData.getColumnName(10),
resultSetMetaData.getColumnName(11), };
return tablemetadata;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:25,代碼來源:RegistrationDAO.java
示例12: viewGroupMembers
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Boolean viewGroupMembers() {
return jdbcTemplate.query("select * from groups",
new ResultSetExtractor<Boolean>() {
public Boolean extractData(ResultSet rs)
throws SQLException, DataAccessException {
boolean b = new File(new File(".").getAbsolutePath()
+ "\\" + "groups").mkdir();
while (rs.next()) {
boolean path = new File(new File("groups")
.getAbsolutePath()
+ "\\" + rs.getString(2)).mkdir();
try {
createUserFloders(rs.getInt(1), new File(
"groups\\" + rs.getString(2))
.getAbsolutePath());
} catch (Exception e) {
// TODO: handle exception
}
}
return true;
}
});
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:25,代碼來源:RegistrationDAO.java
示例13: usergroupcount
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Boolean usergroupcount(final Users users) {
String countuserssql = "select GROUPMEMBERCOUNT from GROUPS where GROUPNAME='"
+ users.getNewgroupname() + "'";
final Boolean usercount = jdbcTemplate.query(countuserssql,
new ResultSetExtractor<Boolean>() {
boolean s;
public Boolean extractData(ResultSet rs)
throws SQLException, DataAccessException {
int i = 0;
if (rs.next()) {
System.out.println(rs.getInt(1));
try {
s = userChangeGroup(rs.getInt(1),
viewGroupname(users));
} catch (Exception e) {
System.out.println(e);
}
}
return s;
}
});
return usercount;
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:27,代碼來源:RegistrationDAO.java
示例14: groupMemberCount
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
public Integer groupMemberCount(String groupname) {
String countuserssql = "select GROUPMEMBERCOUNT from GROUPS where GROUPNAME='"
+ groupname + "'";
final Integer usercount = jdbcTemplate.query(countuserssql,
new ResultSetExtractor<Integer>() {
int i = 0;
public Integer extractData(ResultSet rs)
throws SQLException, DataAccessException {
if (rs.next()) {
i = rs.getInt(1);
}
return i;
}
});
return usercount;
}
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:23,代碼來源:RegistrationDAO.java
示例15: findAllBooks
import org.springframework.jdbc.core.ResultSetExtractor; //導入依賴的package包/類
@Override
public List<Book> findAllBooks(String author) {
// TODO Auto-generated method stub
System.out.println(author);
String FIND_ALL_Author="select * from book where author=?";
return jdbcTemplate.query(FIND_ALL_Author,new String[]{author}, new ResultSetExtractor<List<Book>>() {
List<Book>books=new ArrayList();
@Override
public List<Book> extractData(ResultSet set) throws SQLException, DataAccessException {
// TODO Auto-generated method stub
while(set.next())
{
Book book=new Book();
book.setAuthor(set.getString("author"));
book.setBookName(set.getString("bookName"));
book.setISBN(set.getLong("ISBN"));
book.setPublication(set.getString("publication"));
book.setDescription(set.getString("description"));
books.add(book);
}
return books;
}
});
}