Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RocksJava - Options cannot be instantiated directly #12330

Closed
ghost opened this issue Feb 5, 2024 · 1 comment
Closed

RocksJava - Options cannot be instantiated directly #12330

ghost opened this issue Feb 5, 2024 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 5, 2024

I tried to open the LevelDB database using RocksJava. My IDE writes that options cannot be initialized directly. I took this from the wiki, but the example from the wiki, also contains this error

My code

package org.example;

import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;
import org.rocksdb.RocksIterator;

public class Main {
    public static <Options> void main(String[] args) {

        String dbPath = "db_path";
        RocksDB.loadLibrary();

        try (final Options options = new Options().setCreateIfMissing(false)) {
            try (final RocksDB db = RocksDB.open(options, dbPath)) {
                try (final RocksIterator iterator = db.newIterator()) {

                    for (iterator.seekToFirst(); iterator.isValid(); iterator.next()) {
                        System.out.println(iterator.key() + " -> " + iterator.value());
                    }
                }
            }
        } catch (RocksDBException e) {
            System.err.println(e.getMessage());
        }
    }
}

What could be the problem?
I'm using rocksdbjni 8.10.0

@ghost ghost closed this as completed Feb 5, 2024
@ghost
Copy link
Author

ghost commented Feb 5, 2024

my bad

@ghost ghost reopened this Feb 5, 2024
@ghost ghost closed this as completed Feb 5, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants