Bruce,
Thank you for your info.
I want to test if the database is up.
Please see my code and propose a better solution if you see one.
I did something like this:
try
{
db = (DatabaseImpl) jdo.getDatabase();
db.begin();
conn = (java.sql.Connection) db.getConnection(); // it will throw
:-)
db.commit();
db.close();
}
catch(DatabaseNotFoundException e) {/*...*/}
catch(PersistenceException e) {/* I get an exception here if the
database is shut down. It is some useful message from the DBSM, e.g.
ORA-xxx. */}
As I can see, the transaction must be in progress to open a connection (
_ctx attribute in DatabaseImpl must not be null). BTW, there a way to
open connection without opening a transaction?
The main reason for these probably annoying questions of mine is that
I'm creating a step-by-step introduction to Castor. My intention was
first to show obtaining a connection to database and then in the next
step a simple transaction example. Nevertheless, if this is the "castor
way", I'll accept it as it is. :-)
Regards,
Emir
P.S. Regarding the documentation... I was looking under the "API" link,
and overlooked "Full javadoc" link at the bottom of page. I apologize
for that. :$
-----Original Message-----
From: Bruce Snyder [mailto:[EMAIL PROTECTED]
Sent: 19. ožujak 2004 20:35
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Re: you? - getDatabase() again
I'm not exactly sure what you're trying to achieve, maybe you want
to test that the java.sql.Connection is alive. If this is what
you're trying to achieve, this can certainly be accomplished via
the DatabaseImpl class.
There is most certainly Javadoc for the DatabaseImpl class available
here:
http://www.castor.org/javadoc/org/exolab/castor/jdo/engine/DatabaseImpl.
html
Bruce
--
perl -e 'print
unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
The Castor Project
http://www.castor.org/
Apache Geronimo
http://incubator.apache.org/projects/geronimo.html
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev