I am trying to use OJB with multiple databases and I have defined
repository.xml, repositoryFarAway.xml, and repositoryFarAway_user.xml. They
are appended at the end of this message. This is probably a simple
configuration error. If anyone can find the problem I would appreciate it,
and send a documentation patch concerning "Multiple Databases" (unless I
missed it).
I am trying to store() an object in the "FarAway" database using the
following code:
ProgressReport pr = new ProgressReport();
// Create a new progress report
pr.setJob(" 117-02");
pr.setEntryDate(new Date());
pr.setRemarks("This is a test");
pr.setSuperintendent("Super");
PersistenceBroker broker = null;
try {
broker =
PersistenceBrokerFactory.createPersistenceBroker("repositoryPostgreSQL.xml")
;
broker.store(pr);
} catch (Throwable t) {
t.printStackTrace();
} finally {
if (broker != null) {
broker.close();
}
}
Since I'm getting the following error, I know OJB is not using the correct
jdbc-connection-descriptor:
...
at
com.p6spy.engine.spy.P6PreparedStatement.setObject(P6PreparedStatement.java:
280)
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Un
known Source)
at
org.apache.ojb.broker.platforms.PlatformMsAccessImpl.setObjectForStatement(U
nknown Source)
at
org.apache.ojb.broker.accesslayer.StatementManager.bindSelect(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(Unknown
Source)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown Source)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown Source)
at org.apache.ojb.broker.server.RequestProcessor.execute(Unknown
Source)
at org.apache.ojb.broker.server.ConnectionHandler.run(Unknown
Source)
at java.lang.Thread.run(Thread.java:536)
Thanks!
Corey
*****repository.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a sample metadata repository for the ObJectBridge System.
Use this file as a template for building your own mappings-->
<!-- defining entities for include-files -->
<!DOCTYPE descriptor-repository SYSTEM "repository.dtd" [
<!ENTITY user SYSTEM "repository_user.xml">
<!ENTITY junit SYSTEM "repository_junit.xml">
<!ENTITY internal SYSTEM "repository_internal.xml">
<!ENTITY postgresql SYSTEM "repositoryPostgreSQL_user.xml">
]>
<descriptor-repository version="0.9.5" isolation-level="read-uncommitted">
<!-- The Default JDBC Connection. If a class-descriptor does not specify its
own JDBC Connection,
the Connection specified here will be used. -->
<jdbc-connection-descriptor
platform="MsAccess"
jdbc-level="1.0"
driver="com.p6spy.engine.spy.P6SpyDriver"
protocol="jdbc"
subprotocol="odbc"
dbalias="Forefront Btrieve"
username="KCCCMK"
password="WEBSET"
>
</jdbc-connection-descriptor>
<!-- include user defined mappings here -->
&user;
<!-- include ojb internal mappings here -->
&internal;
<!-- usar data for postgresql database -->
&postgresql
</descriptor-repository>
*****repositoryFarAway.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a sample metadata repository for the ObJectBridge System.
Use this file as a template for building your own mappings-->
<!-- defining entities for include-files -->
<!DOCTYPE descriptor-repository SYSTEM "repository.dtd" [
<!ENTITY postgresql SYSTEM "repositoryPostgreSQL_user.xml">
]>
<descriptor-repository version="0.9.5" isolation-level="read-uncommitted">
<!-- The Default JDBC Connection. If a class-descriptor does not specify its
own JDBC Connection,
the Connection specified here will be used. -->
<jdbc-connection-descriptor
platform="PostgreSQL"
jdbc-level="1.0"
driver="org.sourceforge.jxdbcon.JXDBConDriver"
protocol="jdbc"
subprotocol="postgresql"
dbalias="//energy/kcci"
username="corey"
password=""
>
</jdbc-connection-descriptor>
<!-- usar data for postgresql database -->
&postgresql;
</descriptor-repository>
*****repositoryFarAway_user.xml
<!-- Please keep user defined mappings in this file only
to avoid mixing user defined and system mappings. -->
<!-- Mapping of User defined classes starts here -->
<!-- KCCI Mappings -->
<class-descriptor
class="com.klaasmeyer.kcci.om.equipment.EquipmentReport"
table="equipment_report"
>
<field-descriptor id="1"
name="code"
column="code"
jdbc-type="VARCHAR"
primarykey="true"
/>
<field-descriptor id="2"
name="entryDate"
column="entry_date"
jdbc-type="DATE"
primarykey="true"
conversion="com.klaasmeyer.forefront.om.ojb.ForefrontJavaDate2SqlDateFieldCo
nversion"
/>
<field-descriptor id="3"
name="job"
column="job"
jdbc-type="VARCHAR"
/>
<field-descriptor id="4"
name="downtimeReason"
column="downtime_reason"
jdbc-type="VARCHAR"
/>
<field-descriptor id="5"
name="remarks"
column="remarks"
jdbc-type="VARCHAR"
/>
</class-descriptor>
<class-descriptor
class="com.klaasmeyer.kcci.om.progress.ProgressReport"
table="progress_report"
>
<field-descriptor id="1"
name="job"
column="job"
jdbc-type="VARCHAR"
primarykey="true"
/>
<field-descriptor id="2"
name="entryDate"
column="entry_date"
jdbc-type="DATE"
primarykey="true"
conversion="com.klaasmeyer.forefront.om.ojb.ForefrontJavaDate2SqlDateFieldCo
nversion"
/>
<field-descriptor id="3"
name="superintendent"
column="superintendent"
jdbc-type="VARCHAR"
/>
<field-descriptor id="4"
name="remarks"
column="remarks"
jdbc-type="VARCHAR"
/>
</class-descriptor>
<!-- Mapping of User defined classes ends here -->
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>