大家帮我找找问题,谢谢!
JSP和SQL2000
<%
String s=session.getAttribute( "s ").toString();
String sqlString= "select * from shouTable where s_date like '% "+s+ "% ' ";
try
{ Connection con;
Statement sql1,sql2,sql3;
ResultSet rs,rs1;
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
con=DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=shangdianDB ", "sa ", " ");
sql1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql2=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql3=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=sql1.executeQuery(sqlString);
while(rs.next()){
String e_name=rs.getString( "e_name ");
String e_size=rs.getString( "e_size ");
int count=Integer.parseInt(rs.getString( "amount "));
rs1=sql2.executeQuery( "select * from monthTable where e_name= ' "+e_name+ " ' and e_size= ' "+e_size+ " ' and mon= ' "+s+ " ' ");
if(rs1.next())
int receive=rs1.getInt( "receive ");
int amount=count+receive;
sql3.executeUpdate( "update monthTable set receive= "+amount+ " where e_name= ' "+e_name+ " ' and e_size= ' "+e_size+ " ' and mon= ' "+s+ " ' ");
}
con.close();
}
catch(
SQLException e1)
{
out.print(e1);
}
%>
提示错误:
Generated servlet error:
Syntax error on token "int ", delete this token
小弟新学请大家帮个忙!
------解决方案--------------------因为不加大括号
if(rs1.next())
int receive=rs1.getInt( "receive ");
receive的生命期在这一行