标题:NullPointerException
只看楼主
yinmingzheng13
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2008-4-13
结帖率:100%
 问题点数:0 回复次数:1 
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
Ethip
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:771
专家分:0
注 册:2008-1-18
得分:0 
con = DriverManager.getConnection(url);
这个地方,好像好需要密码,用户名

你的数据库是SQL Server 2000吧,数据库连接是jdbc-odbc桥,这个要找xp下设置数据源。
这种方式不建议采用,用jdbc连接啊!上网搜搜!
2008-12-12 09:45



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




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

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