你创建odbc了么;
应该是你的数据库连接不成功造成的:
给你一个简单的例子:
   public Connection createConnection()
    {
        readFileInfo readfile = new readFileInfo();
        String ip = readfile.getFileInfo("ip");
        String database = readfile.getFileInfo("database");
        //定义jdbc连接oracle的url
        String  strUrl="jdbc:oracle:thin:@" +ip.trim() +":1521:" + database + "";        /**
           创建数据库的连接,返回connection
           */          //定义数据库连接的变量
        Connection  connection=null;
        try
        {
            //定义oracle的driver
            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
            String user=null;
            String password = null;
            user = readfile.getFileInfo("user");
            password = readfile.getFileInfo("password");
            //连接数据库
            connection = DriverManager.getConnection(strUrl,user.trim(),password.trim());
        }
        catch (Exception e)
        {
            System.out.println(e.toString());
        }
        return connection;
    }