db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe Hamelin" <philippe.hameli...@ens.etsmtl.ca>
Subject RE: Pocket PC
Date Thu, 08 Sep 2005 19:12:40 GMT
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



Mime
View raw message