3个回答
2013-07-18
展开全部
public String[] search(){
List<String> list = new ArrayList<String>();
String sql = "select name from user" ;
try {
conn = DBUtil.getConnection();//连接数据库的
ps = conn.prepareStatement(sql);
ResultSet rs= ps.executeQuery();
while(rs.next()){
list.add(rs.getString(1));
}
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
return null ;
}catch(Exception e){
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
String user[] = (String[])list.toArray(new String[list.size()]);
return user;
}
List<String> list = new ArrayList<String>();
String sql = "select name from user" ;
try {
conn = DBUtil.getConnection();//连接数据库的
ps = conn.prepareStatement(sql);
ResultSet rs= ps.executeQuery();
while(rs.next()){
list.add(rs.getString(1));
}
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
return null ;
}catch(Exception e){
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
String user[] = (String[])list.toArray(new String[list.size()]);
return user;
}
2013-07-18
展开全部
package com.declareol.trashbox;
import java.sql.ResultSet;
import java.util.Vector;
import com.declareol.commons.CommConnDataBase;
public class TrashBox {
public String[] strUser;
public void getTrashBox(String strName) {
CommConnDataBase CCDB = new CommConnDataBase();
ResultSet objRsInfo = null;
int intI = 0;
String strSelect = "select * from DOL_OFTEN_CASE";
List <String> list=new ArrayList <String>();
try {
objRsInfo = CCDB.getResult(strSelect);
while (objRsInfo.next()) {
list.add(objRsInfo.getString(3));
intI++;
} catch (Exception e) {
System.out.print(e.getMessage());
} finally {
CCDB.Release();
}
}
public String[] putUser() {
return strUser;
}
}
import java.sql.ResultSet;
import java.util.Vector;
import com.declareol.commons.CommConnDataBase;
public class TrashBox {
public String[] strUser;
public void getTrashBox(String strName) {
CommConnDataBase CCDB = new CommConnDataBase();
ResultSet objRsInfo = null;
int intI = 0;
String strSelect = "select * from DOL_OFTEN_CASE";
List <String> list=new ArrayList <String>();
try {
objRsInfo = CCDB.getResult(strSelect);
while (objRsInfo.next()) {
list.add(objRsInfo.getString(3));
intI++;
} catch (Exception e) {
System.out.print(e.getMessage());
} finally {
CCDB.Release();
}
}
public String[] putUser() {
return strUser;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-18
展开全部
javax.servlet.jsp.jstl这个包里有个ResultSupport
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询