You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Trevor Armstrong <tr...@eecg.toronto.edu> on 2005/09/08 20:59:06 UTC

Pocket PC

Hi,
I'm trying to get Derby working on my Windows Mobile 2003 Pocket PC. First
of all I'm trying to get that simple sample program that comes with Derby
running on it. Unfortunetly this program doesn't make it very far before
crashing at the line that loads the database driver:
            Class.forName(driver).newInstance();

With the exception:

java.lang.ExceptionInInitializerError: java.lang.NullPointerException
	at
org.apache.derby.impl.services.monitor.BaseMonitor.getDefaultImplementations(Unknown
Source)
	at
org.apache.derby.impl.services.monitor.BaseMonitor.runWithState(Unknown
Source)
	at org.apache.derby.impl.services.monitor.FileMonitor.<init>(Unknown Source)
	at org.apache.derby.iapi.services.monitor.Monitor.startMonitor(Unknown
Source)
	at org.apache.derby.iapi.jdbc.JDBCBoot.boot(Unknown Source)
	at org.apache.derby.jdbc.EmbeddedDriver.boot(Unknown Source)
	at org.apache.derby.jdbc.EmbeddedDriver.<clinit>(Unknown Source)
	at java.lang.Class.initializeImpl(Native Method)
	at java.lang.Class.initialize(Unknown Source)
	at java.lang.Class.forNameImpl(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at SimpleApp.go(NoSourceFileNameProvided.java)
	at SimpleApp.main(NoSourceFileNameProvided.java)

I'm using IBM's WebSphere Studio Device Developer and the application is
using CDC/Foundation Profile. Is this sample application even able to run
on a PDA? Is there somewhere I can look for more documentation on getting
Derby running on a Pocket PC?

Thanks in advance,
Trevor


Re: Pocket PC

Posted by Deepa Remesh <dr...@gmail.com>.
The documentation for this is also available in Derby10.1 manuals:
http://db.apache.org/derby/docs/10.1/ref/refderby.pdf (Look for JSR169)
http://db.apache.org/derby/docs/10.1/devguide/derbydev.pdf (Look for DataSource)

Deepa

On 9/8/05, Daniel John Debrunner <dj...@debrunners.com> wrote:
> Trevor Armstrong wrote:
> 
> > Hi,
> > I'm trying to get Derby working on my Windows Mobile 2003 Pocket PC. First
> > of all I'm trying to get that simple sample program that comes with Derby
> > running on it. Unfortunetly this program doesn't make it very far before
> > crashing at the line that loads the database driver:
> >             Class.forName(driver).newInstance();
> 
> CDC/Foundation does not support java.sql.DriverManager/Driver so the
> sample program will not work.
> 
> To obtain a connection you need to use the javax.sql.DataSource api, and
> Derby 10.1 provides the implementation
> org.apache.derby.jdbc.EmbeddedSimpleDataSource
> for CDC/Foundation.
> 
> There is a functiona spec attached to this bug that shows how to use it.
> 
> http://issues.apache.org/jira/browse/DERBY-97
> 
> Dan.
> 
>

Re: Pocket PC

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Trevor Armstrong wrote:

> Hi,
> I'm trying to get Derby working on my Windows Mobile 2003 Pocket PC. First
> of all I'm trying to get that simple sample program that comes with Derby
> running on it. Unfortunetly this program doesn't make it very far before
> crashing at the line that loads the database driver:
>             Class.forName(driver).newInstance();

CDC/Foundation does not support java.sql.DriverManager/Driver so the
sample program will not work.

To obtain a connection you need to use the javax.sql.DataSource api, and
Derby 10.1 provides the implementation
org.apache.derby.jdbc.EmbeddedSimpleDataSource
for CDC/Foundation.

There is a functiona spec attached to this bug that shows how to use it.

http://issues.apache.org/jira/browse/DERBY-97

Dan.


RE: Pocket PC

Posted by Trevor Armstrong <tr...@eecg.toronto.edu>.
Hi Philippe,
thanks for the quick response, I've started using that DatabaseFactory
class that you included however I still get the same exception in
getDefaultImplementations (just with a different call path):

java.lang.NullPointerException at
org.apache.derby.impl.services.monitor.BaseMonitor.getDefaultImplementations(Unknown
Source)
	at
org.apache.derby.impl.services.monitor.BaseMonitor.runWithState(Unknown
Source)
	at org.apache.derby.impl.services.monitor.FileMonitor.<init>(Unknown Source)
	at org.apache.derby.iapi.services.monitor.Monitor.startMonitor(Unknown
Source)
	at org.apache.derby.iapi.jdbc.JDBCBoot.boot(Unknown Source)
	at org.apache.derby.jdbc.EmbeddedSimpleDataSource.findDriver(Unknown Source)
	at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(Unknown
Source)
	at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(Unknown
Source)
	at DatabaseFactory.getConnection(Unknown Source)
	at SimpleApp.go(Unknown Source)
	at SimpleApp.main(Unknown Source)

Any suggestions? It must have something to do with my configuration or
something because the code is pretty straightforward to use.

Thanks in advance,
Trevor


> Hi Trevor,
> I had the same problem. Make sure you put the jdbc.jar in the
> bootclasspath
> (bootstrap classes in eclipse) and derby.jar in the user classpath (users
> classes in eclipse). Here is a snippet of code to start a derby database :
>
> import java.sql.Connection;
> import java.sql.SQLException;
>
> import javax.sql.DataSource;
>
> import org.apache.derby.jdbc.EmbeddedSimpleDataSource;
>
> public class DatabaseFactory {
>
> 	private static final String DB_PATH = "/ Databases/mydb";
>
> 	private static DatabaseFactory instance = null;
>
> 	private EmbeddedSimpleDataSource dataSource = null;
>
> 	static public DatabaseFactory getInstance() {
> 		if(instance == null) {
> 			instance = new DatabaseFactory();
> 		}
> 		return instance;
> 	}
>
> 	public void initDataSource() {
> 		dataSource = new EmbeddedSimpleDataSource();
> 		dataSource.setDatabaseName(DB_PATH);
> 		dataSource.setCreateDatabase("create");
> 	}
>
> 	public DataSource getDataSource() {
> 		if(dataSource == null) {
> 			initDataSource();
> 		}
> 		return (DataSource) dataSource;
> 	}
>
> 	public void closeDataSource() {
> 		try {
> 			if(dataSource != null) {
> 				dataSource.setShutdownDatabase("shutdown");
> 				dataSource.getConnection();
> 			}
> 		} catch (SQLException e) {
>
> 		}
> 	}
>
> 	public Connection getConnection() {
> 		Connection conn = null;
> 		try {
> 			conn = getDataSource().getConnection();
> 		} catch (SQLException e) {
> 			LogFactory.error("Error opening database
> <"+DB_PATH+">");
> 		}
> 		return conn;
> 	}
> }
>
> Hope this help!
>
> Philippe
>
> -----Message d'origine-----
> De : Trevor Armstrong [mailto:trevor@eecg.toronto.edu]
> Envoyé : Thursday, September 08, 2005 2:59 PM
> À : derby-user@db.apache.org
> Objet : Pocket PC
>
> Hi,
> I'm trying to get Derby working on my Windows Mobile 2003 Pocket PC. First
> of all I'm trying to get that simple sample program that comes with Derby
> running on it. Unfortunetly this program doesn't make it very far before
> crashing at the line that loads the database driver:
>             Class.forName(driver).newInstance();
>
> With the exception:
>
> java.lang.ExceptionInInitializerError: java.lang.NullPointerException
> 	at
> org.apache.derby.impl.services.monitor.BaseMonitor.getDefaultImplementations
> (Unknown
> Source)
> 	at
> org.apache.derby.impl.services.monitor.BaseMonitor.runWithState(Unknown
> Source)
> 	at org.apache.derby.impl.services.monitor.FileMonitor.<init>(Unknown
> Source)
> 	at
> org.apache.derby.iapi.services.monitor.Monitor.startMonitor(Unknown
> Source)
> 	at org.apache.derby.iapi.jdbc.JDBCBoot.boot(Unknown Source)
> 	at org.apache.derby.jdbc.EmbeddedDriver.boot(Unknown Source)
> 	at org.apache.derby.jdbc.EmbeddedDriver.<clinit>(Unknown Source)
> 	at java.lang.Class.initializeImpl(Native Method)
> 	at java.lang.Class.initialize(Unknown Source)
> 	at java.lang.Class.forNameImpl(Native Method)
> 	at java.lang.Class.forName(Unknown Source)
> 	at SimpleApp.go(NoSourceFileNameProvided.java)
> 	at SimpleApp.main(NoSourceFileNameProvided.java)
>
> I'm using IBM's WebSphere Studio Device Developer and the application is
> using CDC/Foundation Profile. Is this sample application even able to run
> on a PDA? Is there somewhere I can look for more documentation on getting
> Derby running on a Pocket PC?
>
> Thanks in advance,
> Trevor
>
>
>
>