You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Eric Polino <er...@campgroundautomation.com> on 2008/05/06 17:43:39 UTC

Postgresql

We were using derby and have decided to switch to postgresql.  I have
changed all my adapters and drivers and they seem to be working
properly.  I'm getting issues when I try to run my initialization
script that has always worked before.  It's a pretty simple script.
It's just a whole bunch of inserts that initialize a development db to
work with.  It's complaining that it can't find the tables it's
attempting to insert into.  I think it's pretty fair to assume that
since they aren't there, it's because they weren't created.  Our setup
is pretty simple.  Via an ant script, we use the postgresql adapter to
take the db schema generated by the CayenneModeler to create the db we
need in our postgresql db.

I hope this is enough information to trigger some type of help.  We
are all pretty new to Cayenne.  We were working with derby so far,
simply because it was what the guide had us start with, and we haven't
changed yet.  So, some parts we just do blindly.  TIA for anyone
lending a hand.

Facts i know:
my database exists, i can connect to it via the console
when connecting to my db after trying to build, the tables aren't there
it doesn't fail when attempting to setup the db via the schema
it fails when trying to run some insert statements

Pieces of the build.xml that might be of help:

<!-- generate database schema from data map -->
<echo message="creating new schema for SunriseDB from cayenne data map..."/>
<cdbgen map="${basedir}/src/main/resources/SunriseMap.map.xml"
      adapter="org.apache.cayenne.dba.postgres.PostgresAdapter"
      driver="org.postgresql.Driver"
      url="${jdbc.url}"   NOTE: set to
jdbc:postgresql://localhost:5432/SunriseDB
      droptables="true"
      droppk="true"
      createtables="true"
      createpk="true"
      createfk="true"
      username="sa"
      password="*****" />

    <!-- populate database -->
    <echo message="populating database with test data..."/>
    <sql
      driver="org.postgresql.Driver"
      classpathref="maven.compile.classpath"
      url="${jdbc.url}"
      userid="sa"
      password="*****"
      src="${basedir}/src/main/derby/scripts/dataset1-script"/>

    <sql2
      driver="org.postgresql.Driver"
      classpathref="maven.compile.classpath"
      url="${jdbc.url}"
      userid="sa"
      password="*****"
      script="${basedir}/src/main/derby/binary_data/dataset1-clobs.txt"/>


-- 
Eric Polino
Campground Automated Systems

Re: Postgresql

Posted by Eric Polino <er...@campgroundautomation.com>.
Thanks for the help.  I managed to get it working.  I figured out that
the init scripts weren't portable from derby to postgres.

On Tue, May 6, 2008 at 2:43 PM, Tore Halset <ha...@pvv.ntnu.no> wrote:
>
> On 6. mai. 2008, at 17.43, Eric Polino wrote:
>
>> We were using derby and have decided to switch to postgresql.  I have
>> changed all my adapters and drivers and they seem to be working
>> properly.  I'm getting issues when I try to run my initialization
>> script that has always worked before.
>
> What issues? Do you get an exception? Error messages?
>
> Regards,
>  - Tore, using cayenne and postgres.
>



-- 
Eric Polino
Campground Automated Systems

Re: Postgresql

Posted by Tore Halset <ha...@pvv.ntnu.no>.
On 6. mai. 2008, at 17.43, Eric Polino wrote:

> We were using derby and have decided to switch to postgresql.  I have
> changed all my adapters and drivers and they seem to be working
> properly.  I'm getting issues when I try to run my initialization
> script that has always worked before.

What issues? Do you get an exception? Error messages?

Regards,
  - Tore, using cayenne and postgres.

Re: Postgresql

Posted by Hans Poo <ha...@welinux.cl>.
Eric,

May be the tables are hidden under some schema ?

PostgreSQL organizes as a database with multiple schemas (like oracle). The search_path internal
postgresql variable defines the schema "search order" to find elements.

To find the available structure of your database y recommend to use pgadmin iii or run from console 

# pg_dump myDbName | less

Good luck
Hans

On Tue, 6 May 2008 12:21:59 -0400, Michael Gentry wrote
> This may not matter for your setup, but is the username "sa" correct?
> With PostgreSQL, you typically create a "postgres" database superuser.
> 
> On Tue, May 6, 2008 at 11:43 AM, Eric Polino
> <er...@campgroundautomation.com> wrote:
> > We were using derby and have decided to switch to postgresql.  I have
> >  changed all my adapters and drivers and they seem to be working
> >  properly.  I'm getting issues when I try to run my initialization
> >  script that has always worked before.  It's a pretty simple script.
> >  It's just a whole bunch of inserts that initialize a development db to
> >  work with.  It's complaining that it can't find the tables it's
> >  attempting to insert into.  I think it's pretty fair to assume that
> >  since they aren't there, it's because they weren't created.  Our setup
> >  is pretty simple.  Via an ant script, we use the postgresql adapter to
> >  take the db schema generated by the CayenneModeler to create the db we
> >  need in our postgresql db.
> >
> >  I hope this is enough information to trigger some type of help.  We
> >  are all pretty new to Cayenne.  We were working with derby so far,
> >  simply because it was what the guide had us start with, and we haven't
> >  changed yet.  So, some parts we just do blindly.  TIA for anyone
> >  lending a hand.
> >
> >  Facts i know:
> >  my database exists, i can connect to it via the console
> >  when connecting to my db after trying to build, the tables aren't there
> >  it doesn't fail when attempting to setup the db via the schema
> >  it fails when trying to run some insert statements
> >
> >  Pieces of the build.xml that might be of help:
> >
> >  <!-- generate database schema from data map -->
> >  <echo message="creating new schema for SunriseDB from cayenne data map..."/>
> >  <cdbgen map="${basedir}/src/main/resources/SunriseMap.map.xml"
> >       adapter="org.apache.cayenne.dba.postgres.PostgresAdapter"
> >       driver="org.postgresql.Driver"
> >       url="${jdbc.url}"   NOTE: set to
> >  jdbc:postgresql://localhost:5432/SunriseDB
> >       droptables="true"
> >       droppk="true"
> >       createtables="true"
> >       createpk="true"
> >       createfk="true"
> >       username="sa"
> >       password="*****" />
> >
> >     <!-- populate database -->
> >     <echo message="populating database with test data..."/>
> >     <sql
> >       driver="org.postgresql.Driver"
> >       classpathref="maven.compile.classpath"
> >       url="${jdbc.url}"
> >       userid="sa"
> >       password="*****"
> >       src="${basedir}/src/main/derby/scripts/dataset1-script"/>
> >
> >     <sql2
> >       driver="org.postgresql.Driver"
> >       classpathref="maven.compile.classpath"
> >       url="${jdbc.url}"
> >       userid="sa"
> >       password="*****"
> >       script="${basedir}/src/main/derby/binary_data/dataset1-clobs.txt"/>
> >
> >
> >  --
> >  Eric Polino
> >  Campground Automated Systems
> >


--
Open WebMail Project (http://openwebmail.org)


Re: Postgresql

Posted by Michael Gentry <bl...@gmail.com>.
This may not matter for your setup, but is the username "sa" correct?
With PostgreSQL, you typically create a "postgres" database superuser.

On Tue, May 6, 2008 at 11:43 AM, Eric Polino
<er...@campgroundautomation.com> wrote:
> We were using derby and have decided to switch to postgresql.  I have
>  changed all my adapters and drivers and they seem to be working
>  properly.  I'm getting issues when I try to run my initialization
>  script that has always worked before.  It's a pretty simple script.
>  It's just a whole bunch of inserts that initialize a development db to
>  work with.  It's complaining that it can't find the tables it's
>  attempting to insert into.  I think it's pretty fair to assume that
>  since they aren't there, it's because they weren't created.  Our setup
>  is pretty simple.  Via an ant script, we use the postgresql adapter to
>  take the db schema generated by the CayenneModeler to create the db we
>  need in our postgresql db.
>
>  I hope this is enough information to trigger some type of help.  We
>  are all pretty new to Cayenne.  We were working with derby so far,
>  simply because it was what the guide had us start with, and we haven't
>  changed yet.  So, some parts we just do blindly.  TIA for anyone
>  lending a hand.
>
>  Facts i know:
>  my database exists, i can connect to it via the console
>  when connecting to my db after trying to build, the tables aren't there
>  it doesn't fail when attempting to setup the db via the schema
>  it fails when trying to run some insert statements
>
>  Pieces of the build.xml that might be of help:
>
>  <!-- generate database schema from data map -->
>  <echo message="creating new schema for SunriseDB from cayenne data map..."/>
>  <cdbgen map="${basedir}/src/main/resources/SunriseMap.map.xml"
>       adapter="org.apache.cayenne.dba.postgres.PostgresAdapter"
>       driver="org.postgresql.Driver"
>       url="${jdbc.url}"   NOTE: set to
>  jdbc:postgresql://localhost:5432/SunriseDB
>       droptables="true"
>       droppk="true"
>       createtables="true"
>       createpk="true"
>       createfk="true"
>       username="sa"
>       password="*****" />
>
>     <!-- populate database -->
>     <echo message="populating database with test data..."/>
>     <sql
>       driver="org.postgresql.Driver"
>       classpathref="maven.compile.classpath"
>       url="${jdbc.url}"
>       userid="sa"
>       password="*****"
>       src="${basedir}/src/main/derby/scripts/dataset1-script"/>
>
>     <sql2
>       driver="org.postgresql.Driver"
>       classpathref="maven.compile.classpath"
>       url="${jdbc.url}"
>       userid="sa"
>       password="*****"
>       script="${basedir}/src/main/derby/binary_data/dataset1-clobs.txt"/>
>
>
>  --
>  Eric Polino
>  Campground Automated Systems
>