Connection conn=null;
PreparedStatement pStat=null;
ResultSet rs=null;
try{
conn=DBC.getConnection();
pStat=conn.prepareStatement("select NCPM,CPM from ClassT where CNO='"+Class.getCNO()+"'");
rs=pStat.executeQuery();
if(rs.next())
{
out.print(rs.getString(1));
out.print(rs.getString(2));
Class.setNCPM(rs.getString(1));
Class.setCPM(rs.getString(2));
if(rs.getString(1).compareTo(rs.getString(2))==0)
response.sendRedirect("jsp3.jsp");
else response.sendRedirect("jsp4.jsp");
} }catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(pStat!=null) pStat.close();
if(conn!=null) conn.close();
}
jsp4代码
int i;
Connection conn=null;
PreparedStatement pStat=null;
ResultSet rs=null;
try{
conn=DBC.getConnection();
pStat=conn.prepareStatement("select COUNT(*) from SClassT where SNO='"+Users.getUserName()+"' AND CTR='"+Class.getCTR()+"'");
rs=pStat.executeQuery();
if(rs.next())
{
i=Integer.parseInt(rs.getString(1));
if(i==2)
{
response.sendRedirect("jsp5.jsp");
}
else response.sendRedirect("sclassinsert.jsp");
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(pStat!=null) pStat.close();
if(conn!=null) conn.close();
}
以上是关于选课系统中选课门数的代码,我设置的是限制每人只能选2门,可是运行时却没起作用,麻烦哪位帮我看看
PreparedStatement pStat=null;
ResultSet rs=null;
try{
conn=DBC.getConnection();
pStat=conn.prepareStatement("select NCPM,CPM from ClassT where CNO='"+Class.getCNO()+"'");
rs=pStat.executeQuery();
if(rs.next())
{
out.print(rs.getString(1));
out.print(rs.getString(2));
Class.setNCPM(rs.getString(1));
Class.setCPM(rs.getString(2));
if(rs.getString(1).compareTo(rs.getString(2))==0)
response.sendRedirect("jsp3.jsp");
else response.sendRedirect("jsp4.jsp");
} }catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(pStat!=null) pStat.close();
if(conn!=null) conn.close();
}
jsp4代码
int i;
Connection conn=null;
PreparedStatement pStat=null;
ResultSet rs=null;
try{
conn=DBC.getConnection();
pStat=conn.prepareStatement("select COUNT(*) from SClassT where SNO='"+Users.getUserName()+"' AND CTR='"+Class.getCTR()+"'");
rs=pStat.executeQuery();
if(rs.next())
{
i=Integer.parseInt(rs.getString(1));
if(i==2)
{
response.sendRedirect("jsp5.jsp");
}
else response.sendRedirect("sclassinsert.jsp");
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(pStat!=null) pStat.close();
if(conn!=null) conn.close();
}
以上是关于选课系统中选课门数的代码,我设置的是限制每人只能选2门,可是运行时却没起作用,麻烦哪位帮我看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货