try
{
String ss=request.getParameter("str");
ss=ss.trim();
int num=Inter.paresInt(ss);}
catch(Exception e){}试试行不行,你的程序的错误提示是“数据格式异常”是不是数据超出范围?
{
String ss=request.getParameter("str");
ss=ss.trim();
int num=Inter.paresInt(ss);}
catch(Exception e){}试试行不行,你的程序的错误提示是“数据格式异常”是不是数据超出范围?
String又可以用那个Integer.parseInt();我用的数据库是sqlserver2000
String str=rs.getString("f_id");
str=str.trim();
int num=Inter.ParesInt(str);
str=str.trim();
int num=Inter.ParesInt(str);
另外程序建议这样写
String str=rs.getString("f_id");
System.out.println(":" + str + ":");
str = (str==null?"":str.trim());
try {
int num=Inter.ParesInt(str);
}catch(NumberFormatException e) {
int num=0;//default值,或者其它exception处理
}
另外程序建议这样写
String str=rs.getString("f_id");
System.out.println(":" + str + ":");
str = (str==null?"":str.trim());
try {
int num=Inter.ParesInt(str);
}catch(NumberFormatException e) {
int num=0;//default值,或者其它exception处理
}
rs.getInteger()不就行了吗?
rs.getInteger()不就行了吗?
不是String,也不是int,更不是。
赫赫
有没有next()while(rs.next())
{
.
.
.
}
int num=Inter.ParesInt(str);
}
楼主,你的记录指针下移了没?
有没有next()while(rs.next())
{
.
.
.
}
你还需要看获取的字符串是否为空
while (rs.next()) {
String str=rs.getString("f_id");
System.out.println(":" + str + ":");
str = (str==null?"":str.trim());
try {
int num=Inter.ParesInt(str);
}catch(NumberFormatException e) {
int num=0;//default值,或者其它exception处理
}
}
}