See inline...

On Thu, 2002-03-07 at 10:23, David Blevins wrote:
> Using PostgreSQL 7.1.2 in Cygwin 1.3.2, I'm also using the jdbc driver that
> comes with 7.1.2

First recommendation is not to use that driver.  Its flawed.  The Castor
group had to patch the PostgreSQL 7.1.x driver because of some bugs. 
You can download a 7.2 driver from jdbc.postgresql.org or use the one in
Castor's CVS repository.  (That driver is the reason why you see me on
the PostgreSQL jdbc mailing lists... I wanted to make sure the changes
made here were submitted.) Also, the 7.2 driver is 'backward' compatible
with 7.1.x so you don't have to upgrade your database. (But you should,
since 7.1.2 has bugs that were fixed in 7.1.3 and performance gains in
7.2)

(Also, note that I've never run PostgreSQL on windows.  Specifically, I
don't run windows at all, so variations on your environment I may not be
aware of.)
 
> I ripped the port number out of my JDBC url and got everything running.
> Although 5432 clearly looks like a bogus port, I saw it in all the

Just so you know, PostgreSQL opens port 5432 for communications.  Its
not a 'bogus' port, its real.  That's how TCP sockets connect to the
PostgreSQL server. However, you don't need to list that port in the
driver since its the default port.  See 
       http://www.postgresql.org/idocs/index.php?jdbc-use.html
and look at the port information for specifics.

> PostgreSQL and Castor docs, so I took it on faith that it worked -- it
> doesn't.  The castor docs should be updated to remove this unneeded port
> from the examples.  Had that been the case, I never would have had the
> problem.

I can't imagine why this would have worked without the port number, but
not with.  (And I highly doubt that its a windows issue, but again, I
don't really know that.)  As long as it works...

> Anyway, new problem now.  Of course now that I have it running, I
> immediately notice I need to setup a keygenerator for handling a PostgreSQL
> sequence.  You don't happen to have a few example handy do you?

If you use the CVS version of castor, (as opposed to 0.9.3.9) you can
set the sequence key to {0}_{1}_seq instead of the default of {0}_seq. 
The {0} maps to the table name, and {1} to the column name.  Since
postgresql SERIAL type creates this by default, it works great.  Simply
do this in the head of your mapping file:

<key-generator name="SEQUENCE">
  <param name="sequence" value="{0}_{1}_seq"/>
</key-generator>

and when you you the key-generator in your class tag to SEQUENCE, then
you'll be able to map to the default sequence.

<class name="yourObject" identity="id" key-generator="SEQUENCE">
....

Word of caution: Currently Castor handles sequences with PostgreSQL by
getting the sequence first, and then using it to insert objects into the
table. (As opposed to the technique that I'm trying to work on, which is
do it in one request, where the returning value is the sequence number) 
The reason is due to limitations with PostgreSQL and its driver.  I'm
hoping that PostgreSQL 7.3 will have changes in it for this.  (This is
the 'returning' example seen at
           http://castor.exolab.org/key-generator.html
that I want to be able to support.  I'm currently in the mindset that
this is too much work for too little benefit until PostgreSQL driver
support the SQL RETURNING clause.  The getInsertedOid() that is
currently used by Castor should likely drop, since the method is
deprecated in the JDBC driver...)

> Thanks!
> David
> 
> > -----Original Message-----
> > From: Ned Wolpert [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, March 07, 2002 10:48 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] Castor and PostgreSQL
> >
> >
> > David-
> >
> >   I've not seen the specific problem you are having. What version of
> > postgresql are you using, and what 'version' of the postgresql driver?
> > I use 7.2, with the driver in that release. (Though the driver in the
> > Castor repository should work too.) When I use the postgresql data
> > source, I configure it like this: (for my local postgres installation,
> > with the database name 'mediamgmt')
> >
> > <database name="mediamgmt" engine="postgresql">
> >   <data-source class-name="org.postgresql.PostgresqlDataSource">
> >      <params database-name="mediamgmt"  user="user"
> >           password="password" server-name="localhost"/>
> >   </data-source>
> > ...
> >
> > and as a driver, this way:
> >
> > <database name="knowledgenet" engine="postgresql">
> >   <driver class-name="org.postgresql.Driver"
> >           url="jdbc:postgresql://localhost/mediamgmt">
> >      <param name="user" value="user"/>
> >      <param name="password" value="password"/>
> >   </driver>
> >   ...
> >
> >
> >
> > On Thu, 2002-03-07 at 09:08, David Blevins wrote:
> > > Hi all,
> > >
> > > I trying to use Castor against PostgreSQL and having no luck.
> > With a config
> > > like this:
> > >
> > > <database name="Local_TX_Database" engine="postgresql" >
> > >     <driver class-name="org.postgresql.Driver"
> > >              url="jdbc:postgresql://127.0.0.1:5432/openejbtest">
> > >         <param name="user" value="openejbuser" />
> > >         <param name="password" value="javaone" />
> > >     </driver>
> > >
> > > ...I get this exception:
> > >
> > > org.exolab.castor.jdo.PersistenceException: Nested error:
> > > java.sql.SQLException: ERROR:  entity: Permission denied.
> > >
> > > This is strange, because if I use that same information against
> > PostgreSQL's
> > > JDBC driver directly, it works just fine.
> > >
> > > try{
> > >     Class.forName("org.postgresql.Driver");
> > >     Connection conn =
> > > DriverManager.getConnection("jdbc:postgresql://127.0.0.1/openejbtest",
> > > "openejbuser","javaone");
> > >     Statement stmt = conn.createStatement();
> > > } catch (Exception e){
> > >     e.printStackTrace();
> > > }
> > >
> > > I tried using the other way of configuring Castor for
> > PostgreSQL as shown at
> > > the website (which has a typo in it BTW, the 's' is missing
> > from 'params' in
> > > the first PosgreSQL example).
> > >
> > > <database name="Local_TX_Database" engine="postgresql" >
> > >     <data-source class-name="org.postgresql.PostgresqlDataSource">
> > >         <param server-name="127.0.0.1" port-number="5432"
> > > database-name="openejbtest"
> > >                 user="openejbuser" password="javaone" />
> > >     </data-source>
> > >
> > > This gives me the infamous NullPointerException at
> > > org.postgresql.Connection.openConnection(Connection.java:148).  I am
> > > familiar with this error as I ran across it in my previous
> > tests with just
> > > JDBC and PostgreSQL alone, it turned out that I had left the
> > database name
> > > out of my JDBC URL as in:
> > >
> > >
> > DriverManager.getConnection("jdbc:postgresql://127.0.0.1/","openej
> > buser","ja
> > > vaone");
> > > When I caught the mistake and added the database name to the
> > end of the URL,
> > > everything worked fine.  Maybe Castor is having the same trouble?
> > >
> > > Anyway, none of my Castor/PostgreSQL attempts seem to work.  Any ideas?
> > >
> > > Thanks,
> > > David
> > >
> > > -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing, send mail to
> > > [EMAIL PROTECTED] with a subject of:
> > >   unsubscribe castor-dev
> > --
> >
> > Virtually,
> > Ned Wolpert <[EMAIL PROTECTED]>
> >
> > D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45
> >
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev
-- 

Virtually, 
Ned Wolpert <[EMAIL PROTECTED]>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to