int MaxLength = -1;
try
{
if(rs.getInt(3) != -1)
{
MaxLength = rs.getInt(3);//可用词中最大词长 可能抛出异常
}
}
catch(Exception e)
{
System.out.println("ERROR!");
return MaxLength;
}
怎么老是出错啊?
总是出错,而执行catch中的内容?
try
{
if(rs.getInt(3) != -1)
{
MaxLength = rs.getInt(3);//可用词中最大词长 可能抛出异常
}
}
catch(Exception e)
{
System.out.println("ERROR!");
return MaxLength;
}
怎么老是出错啊?
总是出错,而执行catch中的内容?
int MaxLength = -1;
try
{
int temp = rs.getInt(3);
if(temp != -1)
{
MaxLength = temp;
}
}
catch(Exception e)
{
System.out.println("ERROR!");
return MaxLength;
}
你对同一列做两次getInt(3)会有问题的
int MaxLength = -1;
try
{
int temp = rs.getInt(3);
if(temp != -1)
{
MaxLength = temp;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
return MaxLength;
}
出错输出是:Before start of result set
你的代码
}
int MaxLength = -1;
try
{
if(rs.next()&&rs.getInt(3) != -1)
{
MaxLength = rs.getInt(3);//可用词中最大词长 可能抛出异常
}
}
catch(Exception e)
{
System.out.println("ERROR!");
return MaxLength;
}
catch(Exception e){
e.printStackTrace();//看看你的出错信息是什么!按你那样异常信息都丢了!SQLException出这个异常了,怀疑你的columnIndex有问题!
}