VJDK - null pointer exception

Rodrigo Hjort rodrigo.hjort at actumplus.com.br
Thu Aug 14 14:23:23 CDT 2003


In the code below (using VJDK's latest release):

import java.awt.*;
import java.awt.event.*;
import com.paradigmasoft.valentina.vjdk.*;

class BaseVDB extends Frame {

 public static void main(String args[])
 {
  System.out.println("Starting BaseVDB...");

  try
  { 
   VJDK.init(4 * 1024 * 1024, "", "");
   VJDK.setDebugLevel(2);

   VDataBase db = new VDataBase();   
   db.create("MeuBanco.vdb");

   VBaseObject boCliente = db.getBaseObject("Cliente");
   if (boCliente == null)
   {
    System.out.println("Creating table Cliente...");
    boCliente = db.makeNewBaseObject("Cliente");
    
    /* below happens the exception */
    VField fldCodigo = boCliente.makeNewField("Codigo", VJDK.TypeShort);
    VField fldNome = boCliente.makeNewField("Nome", VJDK.TypeString, 40);
    VField fldDataNasc = boCliente.makeNewField("DataNasc", VJDK.TypeDate);
    fldCodigo.setFlags(VJDK.fIndexed);    
   }
   else
   {
    System.out.println("Table Cliente already exists.");
   }
   db.dump("MeuBanco.xml");

   db.flush(); /*save to disk*/
   db.close();
   VJDK.shutdown();

  }
  catch (VException vx)
  {
   int errCode = vx.getErrorCode();
   String errStr = vx.getErrorString();
   System.out.println("Erro VJDK: " + errCode + " - " + errStr);
  }
 }

 private VDataBase db;
}

"Exception in thread "main" java.lang.NullPointerException
        at myprojects.basevdb.BaseVDB.main(BaseVDB.java:94)"

It gets compiled, but when started the application the error ocurrs at that point. What could be wrong?! If those lines which contains .makeNewField() are excluded, the error ceases.

By the way, the VJDK documentation in PDF has some syntax errors. i.g.:
VJDK.init() -> VJDK.Init()
VDataBase.create() -> VDataBase.CreateDataBase()
VDataBase.getBaseObject() -> VDataBase.GetBaseObject()


Regards,

Rodrigo Hjort
rodrigo.hjort at actumplus.com.br



More information about the Valentina mailing list