This topic applies to Java version only
Symbian OS is the global industry standard operating system for smartphones. You can find more information about it at http://www.symbian.com/.
UIQ (formerly known as User Interface Quartz) is a software platform based upon Symbian OS. UIQ-based devices support Java thus enabling you to use db4o.
Db4o was tested for compatibility with UIQ 2.1 SDK. You can download the SDK from:
http://developer.sonyericsson.com/site/global/docstools/symbian/p_symbian.jsp
The
UIQ Symbian SDK allows you to write applications for Symbian OS using
your Windows PC and a suitable JDK ( JDK 1.1.8). The SDK comes with UIQ
emulator, which can be run on a Windows-based computer allowing you to
test and debug your application before deployment.
The SDK also installs some third party software, including JRE 1.3, which under some conditions can break Java installations already present ('java.dll not found' error message). In this case you can uninstalling the JRE that comes with Symbian to solve the problem.
The Emulator has its own file system ( you can get more information about how it is designed from the SDK documentation).
To be able to run Java applications and use db4o in the emulator, you will have to map _epoc_drive_j to \epoc32\java. Consult your MS Windows documentation on how to set environment variables.
Environment variables can be set locally at the command prompt using the syntax
set _epoc_drive_j=\epoc32\java\
You can also launch your application on the Emulator from the Windows command prompt:
pjava -cd j:\demo DemoApp
You have to ensure that the correct version of the emulator VM executable (pjava.exe) is used - the correct path is /runtime/epoc32/release/wins/urel.
Command-line launch also allows you to pass arguments to a class's main(). Please, note that path names given to pjava are paths within the Emulator's drivespace only; they are not Windows paths.
Some platforms will require additional tuning to run the Emulator successfully. The following advices should help, if you are experiencing problems running the emulator:
The last thing you need to do is to copy the proper version of db4o jar (JDK1.1) to the emulator file system directory (/runtime/epoc32/java) and add its location to the classpath.
To make the startup process easier we recommend to create a batch file to run your application, which can look like this:
REM deploy all db4o files to C:\Symbian\UIQ_21\runtime\epoc32\java
SET SYMB_HOME=C:\Symbian\UIQ_21
SET SYMB_EPOC32=%SYMB_HOME%\runtime\epoc32
SET SYMB_BIN=%SYMB_EPOC32%\release\wins\urel
SET _epoc_drive_j=%SYMB_EPOC32%\java\
%SYMB_BIN%\pjava -cd J:\ -cp .;J:\;J:\classes\;J:\db4o-5.0-java1.1.jar;J:\DemoApp.jar DemoClass
Tested version of Symbian JDK has problems with IO:
To workaround these problems and make db4o file operations stable special SymbianIoAdapter is provided for Symbian OS:
Db4o.configure().io(new com.db4o.io.SymbianIoAdapter())
You can read more about using IOAdapters with db4o in IOAdaper chapter
The following example shows how SymbianIoAdapter can be used:
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02
03
package com.db4odoc.f1.symbian; 04
05
06
import java.io.File; 07
import java.io.IOException; 08
09
10
import com.db4o.Db4o; 11
import com.db4o.ObjectContainer; 12
import com.db4o.ObjectSet; 13
14
15
16
public class SymbianTest { 17
18
public static final String YAPFILENAME = "formula1.yap"; 19
20
public static void main(String[] args) throws IOException { 21
setObjects(); 22
setObjectsSymbian(); 23
getObjects(); 24
getObjectsSymbian(); 25
} 26
// end main 27
28
public static void setObjects(){ 29
System.out.println("\nSetting objects using RandomAccessFileAdapter"); 30
new File(YAPFILENAME).delete(); 31
Db4o.configure().io(new com.db4o.io.RandomAccessFileAdapter()); 32
try { 33
ObjectContainer db = Db4o.openFile(YAPFILENAME); 34
try { 35
db.set(new SymbianTest()); 36
} finally { 37
db.close(); 38
} 39
} catch (Exception ex){ 40
System.out.println("Exception accessing file: " + ex.getMessage()); 41
} 42
} 43
// end setObjects 44
45
public static void setObjectsSymbian(){ 46
System.out.println("\nSetting objects using SymbianIoAdapter"); 47
new File(YAPFILENAME).delete(); 48
Db4o.configure().io(new com.db4o.io.SymbianIoAdapter()); 49
try { 50
ObjectContainer db = Db4o.openFile(YAPFILENAME); 51
try { 52
db.set(new SymbianTest()); 53
} finally { 54
db.close(); 55
} 56
} catch (Exception ex){ 57
System.out.println("Exception accessing file: " + ex.getMessage()); 58
} 59
} 60
// end setObjectsSymbian 61
62
public static void getObjects(){ 63
System.out.println("\nRetrieving objects using RandomAccessFileAdapter"); 64
Db4o.configure().io(new com.db4o.io.RandomAccessFileAdapter()); 65
try { 66
ObjectContainer db = Db4o.openFile(YAPFILENAME); 67
try { 68
ObjectSet result=db.get(new Object()); 69
System.out.println("Objects in the database: " + result.size()); 70
} finally { 71
db.close(); 72
} 73
} catch (Exception ex){ 74
System.out.println("Exception accessing file: " + ex.getMessage()); 75
} 76
} 77
// end getObjects 78
79
public static void getObjectsSymbian(){ 80
System.out.println("\nRetrieving objects using SymbianIoAdapter"); 81
Db4o.configure().io(new com.db4o.io.SymbianIoAdapter()); 82
try { 83
ObjectContainer db = Db4o.openFile(YAPFILENAME); 84
try { 85
ObjectSet result=db.get(new Object()); 86
System.out.println("Objects in the database: " + result.size()); 87
} finally { 88
db.close(); 89
} 90
} catch (Exception ex){ 91
System.out.println("Exception accessing file: " + ex.getMessage()); 92
} 93
} 94
// end getObjectsSymbian 95
}