JAVA中列表框List,如何在数据库中读取数据传递到JSP
RT,数据库部分,如何传递到JSP中publicstaticListgetDepartmentList(){ResultSetrs=null;Strstr=newStr(...
RT,数据库部分,如何传递到JSP中
public static List getDepartmentList( )
{
ResultSet rs=null;
Str str=new Str();
String sql=null;
int i=0,j=0;
List<String> DepartmentList = new ArrayList<String>();
sql="select DepartmentName from Department";
try
{
try
{
conn=getConnection();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=st.executeQuery(sql);
while(rs.next()){
i++;
}
DepartmentList.add(rs.getString(3));
}
catch( SQLException ex )
{
ex.printStackTrace( System.err );
}
finally
{
close(rs,st,conn);
}
return DepartmentList;
} 展开
public static List getDepartmentList( )
{
ResultSet rs=null;
Str str=new Str();
String sql=null;
int i=0,j=0;
List<String> DepartmentList = new ArrayList<String>();
sql="select DepartmentName from Department";
try
{
try
{
conn=getConnection();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=st.executeQuery(sql);
while(rs.next()){
i++;
}
DepartmentList.add(rs.getString(3));
}
catch( SQLException ex )
{
ex.printStackTrace( System.err );
}
finally
{
close(rs,st,conn);
}
return DepartmentList;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |