当前位置: 代码迷 >> J2SE >> 经常做日本项目的朋友,请求帮忙!解决思路
  详细解决方案

经常做日本项目的朋友,请求帮忙!解决思路

热度:75   发布时间:2016-04-24 13:21:36.0
经常做日本项目的朋友,请求帮忙!!

当我点"下一条"按钮,直到点到最后一条,出现了上图出现的错误的错误,不直到什么意思,看看我的代码
Java code
    private static ResultSet rs=null;    private static Statement aStatement=null;    private static Connection aConnection=null;private static void getDBConnection()    {        try        {            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");            aConnection=DriverManager.getConnection("jdbc:odbc:mydata","sa","sa");        }catch(ClassNotFoundException e1)        {            JOptionPane.showMessageDialog(null, "驱动没找到,连接失败","Error",JOptionPane.ERROR_MESSAGE);                    }catch(SQLException e2)        {            JOptionPane.showMessageDialog(null, "用户名密码错误,连接失败","Error",JOptionPane.ERROR_MESSAGE);                    }    }public static Vector getAll()    {        Vector <Category> Categories=new Vector();        String strSQL;        strSQL="SELECT * FROM Categories";        try        {            getDBConnection();            aStatement=aConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);            rs=aStatement.executeQuery(strSQL);            while (rs.next())            {                Category aCategory=new Category();                aCategory.setCategoryID(rs.getInt("CategoryID"));                aCategory.setCategoryName(rs.getString("CategoryName"));                aCategory.setDescription(rs.getString("Description"));                byte [] buf1=rs.getBytes("Picture");                aCategory.setPicture(buf1);                                Categories.add(aCategory);            }            rs.first();        }        catch(SQLException e)        {            JOptionPane.showMessageDialog(null, e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);                    }        return Categories;    }public static Category GetNextCategory()    {        Category aCategory=new Category();        try        {            if (rs.isLast())            {                JOptionPane.showMessageDialog(null, "已经是最后一条记录了","提示",JOptionPane.INFORMATION_MESSAGE);            }            else            {                rs.next();                            }            aCategory=getCategory(rs);        }catch(SQLException e)        {            JOptionPane.showMessageDialog(null, e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);                    }        return aCategory;    }

以上是部分代码,欢迎高手们协助解决!

------解决方案--------------------
错误是说的你的索引index不正确
这些方法都是在什么时候调用的?aCategory=getCategory(rs);//getCategory的代码呢?估计就是在这里出错的

if (rs.isLast())
{
JOptionPane.showMessageDialog(null, "已经是最后一条记录了","提示",JOptionPane.INFORMATION_MESSAGE);

}

改成
if (rs.isAfterLast())
{
JOptionPane.showMessageDialog(null, "已经是最后一条记录了","提示",JOptionPane.INFORMATION_MESSAGE);
return; //这里就返回



试试看吧


------解决方案--------------------
支持!!!
日語的意思就是說索引index不正确。

------解决方案--------------------
把附件保存成jpg,bmp太大了
eclipse 没有报错因为你catch了


Java code
 catch(SQLException e)        {           e.printStackTrace();//加这个就可以看到控制台里详细信息了            JOptionPane.showMessageDialog(null, e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);                    }
  相关解决方案