Firebase未被写入,并且没有错误被抛出

时间:2017-02-25 21:46:10

标签: java firebase firebase-realtime-database

我正在创建一个Web应用程序,我将Firebase用作我的主数据库。

对于一些原型,我已经能够根据需要更新数据并将数据写入数据库,但几周前,在我更新SDK之前和之后,它已经停止添加到数据库中。 这是我调用和写入数据库的代码

DatabaseReference data;

public void Send(String jobName, Genome currentGenome, Gene currentGene) throws FileNotFoundException {
    FileInputStream serviceAccount = new FileInputStream(ResultstoFirebaseCopy.class.getClassLoader()
            .getResource("<Admin Authentication>.json").getPath()
            .replaceAll("%20", " "));

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
            .setDatabaseUrl("https://<projectname>.firebaseio.com/").build();

    FirebaseApp.initializeApp(options);

    data=FirebaseDatabase.getInstance().getReference();

    // loop through with results from genome class
    System.out.println(currentGenome.getGenome());

    DatabaseReference cellref = Genespot.child(jobName).child(currentGenome.getKingdom())
            .child(currentGenome.getSubType()).child(currentGenome.getTaxID())
            .child(currentGenome.getGenome().replace('.', 'v')).child(currentGene.getName());

    Hit[] hits = currentGene.getHits();

    cellref.child("Hit Count").setValue(hits.length, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError arg0, DatabaseReference arg1) {
            throw arg0.toException();
        }
    });

    int i = 0;

    while (i < hits.length) {
        cellref.child("Hit" + (i + 1)).child("Accession Number").setValue(
                hits[i].getAccesionNumber().replace('.', 'v'), new DatabaseReference.CompletionListener() {
                    @Override
                    public void onComplete(DatabaseError arg0, DatabaseReference arg1) {
                        throw arg0.toException();
                    }
                });
        cellref.child("Hit" + (i + 1)).child("Hit From").setValue(hits[i].getHitFrom(),
                new DatabaseReference.CompletionListener() {
                    @Override
                    public void onComplete(DatabaseError arg0, DatabaseReference arg1) {
                        throw arg0.toException();
                    }
                });
        cellref.child("Hit" + (i + 1)).child("Hit To").setValue(hits[i].getHitTo(),
                new DatabaseReference.CompletionListener() {
                    @Override
                    public void onComplete(DatabaseError arg0, DatabaseReference arg1) {
                        throw arg0.toException();
                    }
                });

        i++;
    }
}

读取和写入访问权限都是正确的,没有任何东西被抛回给我。

0 个答案:

没有答案