标题:NullPointerException
取消只看楼主
yinmingzheng13
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2008-4-13
结帖率:100%
 问题点数:0 回复次数:0 
NullPointerException

import java.sql.*;
import java.util.*;

class JDBC_test
{
    public static void main(String[] args)
    {
           Connection con ;
        Statement stm ;
        ResultSet rs;
        String url ;
        
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            
            url = "jdbc:odbc:ymz";
            
            con = DriverManager.getConnection(url);
            
            stm = con.createStatement();
            
            rs = stm.executeQuery("SELECT * FROM sysusers");
            
            while(rs.next())
            {
                Vector vector = new Vector();
                //System.out.println("OK");
                for(int i=0;;i++)
                {
                    vector.addElement(rs.getObject(i+1).toString());
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                }
                //System.out.println("OK");
                //System.out.println(vector);
            }
            
            /*
            while(rs.next())
            {
                //int theInt = rs.getInt("uid");
                String str = rs.getString("createdate");
                System.out.println(str);
            }
            */
        }catch(Exception e){
            e.printStackTrace();
        }
        
    }
}
搜索更多相关主题的帖子: 数据库 Vector 
2008-12-10 16:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-248627-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.396870 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved