I'm newer in ojb.
Can anyone help me ? I got the followinf exception when trying the jdo plugin :
java.lang.NullPointerException
at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:86)
at org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreMa
nager.java:271)
at com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
Source)
at com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unkn
own Source)
at org.apache.ojb.tshi.Test1.main(Unknown Source)
Here are my classes :
/**
* Testing AdressImpl with JDO : Test1.java
*/
package org.apache.ojb.tshi;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Vector;
import java.util.Collection;
import java.util.Iterator;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import javax.jdo.Extent;
import org.apache.ojb.broker.PersistenceBrokerFactory;
import org.apache.ojb.broker.util.ui.AsciiSplash;
import org.apache.ojb.jdori.sql.OjbStorePMF;
import org.apache.ojb.jdori.sql.OjbExtent;
public class Test1
{
public static void main(String[] args)
{
PersistenceManagerFactory factory;
PersistenceManager manager;
try
{
/*
* SETUP JDO
*/
// first create a persistence manager factory
factory = new OjbStorePMF(); // have to use this to make it easily portable, should
get factory from JNDI or something
// now retrieve the persistence manager
manager = factory.getPersistenceManager();
/*
* START A TRANSACTION
*/
// retrieve the current transaction
Transaction t = manager.currentTransaction();
// start a new transaction
t.begin();
/*
* CREATE AN OBJECT INSTANCE
*/
AddressImpl a =
new AddressImpl ("7700 Technology Way", "NONNULL", "Denver", "CO", "80237");
/*
* MAKE THE OBJECT PERSISTENT
*/
manager.makePersistent(a);
/*
* COMMIT THE OBJECT TO STORAGE
*/
// commit the transaction, all changes made between
// the begin and the commit are set to the db
t.commit();
/*
* RETRIEVING ALL ADDRESSES
*/
System.out.println("RETRIEVING ADDRESSES...");
Extent ext = manager.getExtent(AddressImpl.class, false);
System.out.println("A new OjbExtent instance created...");
String filter = "addressLine1==line1";
Query query = manager.newQuery(ext, filter);
System.out.println("A new query created with extent and filter...");
String parameter = "String line1";
query.declareParameters (parameter);
System.out.println("Parameter declared...");
Collection c = (Collection) query.execute("7700 Technology Way");
System.out.println("Query executed with parameter and cast to Collection...");
Iterator i = c.iterator();
while (i.hasNext())
{
AddressImpl addr = (AddressImpl) i.next();
System.out.println (
"Address : "
+ addr.getAddressLine1()
+ ", "
+ addr.getAddressLine2()
+ ", "
+ addr.getCity()
+ ", "
+ addr.getState()
+ ", "
+ addr.getZip() );
}
/*
* CLEANUP AND EXIT
*/
manager.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
/**
* AdrressImpl.java
*/
package org.apache.ojb.tshi;
public class AddressImpl {
public String addressLine1;
public String addressLine2;
public String city;
public String state;
public String zip;
public AddressImpl()
{ addressLine1 = "stillnull";
addressLine2 = "stillnull";
city = "stillnull";
state = "stillnull";
zip = "stillnull";
}
public AddressImpl (String addr1, String addr2, String city, String state, String
zip) {
addressLine1=addr1;
addressLine2=addr2;
this.city=city;
this.state=state;
this.zip=zip;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1=addressLine1;
}
public String getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2=addressLine2;
}
public String getCity() {
return city;
}
public void setCity (String city) {
this.city=city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state=state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip=zip;
}
}
Thinks in advance.
tshitshi
---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs