对数据库进行排序 查看一下查询条件及数据库结果 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你就不能一次取出?分两次做什么? 建议你不要用vector存值,用Map---------- public static List executeQuery(String sql) throws Exception { List list = new ArrayList(); Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = openConnection(); stmt = conn.createStatement(); rs = stmt.executeUpdate(sql); ResultSetMetaData rsmd = rs.getMetaData(); while ( rs.next() ) { Map map = new HashMap(); for ( int i = 1; i <= rsmd.getColumnCount(); i++ ) { map.put(rsmd.getColumnName(i), rs.getString(i) == null ? "" : rs.getString(i)); } list.add(map); } } catch ( Exception e ) { e.printStackTrace(); } finally { if ( rs != null ) rs.close(); closeConnection(conn); } return list; }----------// 使用前记得import java.util.*;List list = executeQuery("select GH_Num, EPRMzhNum from S_GUAHAO where KS_ID='"+orgId+"'and flag='no'");// 方法一:按名字取值for ( int i = 0; i < list.size(); i++ ){ Map map = (HashMap)list.get(i); out.println((String)mag.get("GH_Num")); out.println((String)mag.get("EPRMzhNum"));} // 方法二:遍历取值for ( int i = 0; i < list.size(); i++ ){ Map map = (HashMap)list.get(i); for (Iterator it = map.keySet().iterator(); it.hasNext();) { String column_name = (String)it.next(); out.println("column name = " + column_name); out.println("column value = " + (String)map.get(column_name)); }} jsp运行中出现如下问题。 框架页面的跳转 导入项目,出现问题! web开发中遇到proxool配置的问题!希望有高手指点! 急!!!关于html编码的问题 访问Tomcat以外的文件夹内的文件 生成XML时内存溢出问题 c3p0的配置问题,有一点小问题,大家帮忙看看,郁闷好长时间了 请推荐可以编写和编译servlet的工具 谁能找出错误在那里?? 小妹初学,jsp环境配置好了,不知道怎样预览页面了? 试问高手
public static List executeQuery(String sql) throws Exception
{
List list = new ArrayList();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
conn = openConnection();
stmt = conn.createStatement();
rs = stmt.executeUpdate(sql);
ResultSetMetaData rsmd = rs.getMetaData();
while ( rs.next() )
{
Map map = new HashMap();
for ( int i = 1; i <= rsmd.getColumnCount(); i++ )
{
map.put(rsmd.getColumnName(i), rs.getString(i) == null ? "" : rs.getString(i));
}
list.add(map);
} }
catch ( Exception e )
{
e.printStackTrace();
}
finally
{
if ( rs != null ) rs.close();
closeConnection(conn);
}
return list;
}----------// 使用前记得import java.util.*;List list = executeQuery("select GH_Num, EPRMzhNum from S_GUAHAO where KS_ID='"+orgId+"'and flag='no'");// 方法一:按名字取值
for ( int i = 0; i < list.size(); i++ )
{
Map map = (HashMap)list.get(i); out.println((String)mag.get("GH_Num"));
out.println((String)mag.get("EPRMzhNum"));
} // 方法二:遍历取值
for ( int i = 0; i < list.size(); i++ )
{
Map map = (HashMap)list.get(i); for (Iterator it = map.keySet().iterator(); it.hasNext();)
{
String column_name = (String)it.next();
out.println("column name = " + column_name);
out.println("column value = " + (String)map.get(column_name));
}
}