persistence@glassfish.java.net

Re: How to change SQL-statements for Persistence Unit

From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
Date: Tue, 21 Mar 2006 13:30:57 -0800

Hi Dmitry
  The entries for PostgreSQLPool that you have provided do not seem to
be correct. Can you send out these pool entries as they appear in your
domain.xml associated with your server.

The entries should be pointing to a valid postgresql database. Again my
suspicion is that the jdbc/PostgreSQL jdbc resource is not configured
correctly.

Let me explain w.r.t the postgres connection that I have set up here :


 <resources>
    <jdbc-resource enabled="true" jndi-name="jdbc/PostgreSQL"
object-type="user" pool-name="PostgresPool"/>
...
    <jdbc-connection-pool allow-non-component-callers="false"
connection-validation-method="auto-commit"
datasource-classname="org.postgresql.ds.PGSimpleDataSource"
fail-all-connections="false" idle-timeout-in-seconds="300"
is-connection-validation-required="false"
is-isolation-level-guaranteed="false" max-pool-size="32"
max-wait-time-in-millis="60000" name="PostgresPool"
non-transactional-connections="false" pool-resize-quantity="2"
res-type="javax.sql.DataSource" steady-pool-size="8">
      <property name="PortNumber" value="5432"/>
      <property name="Password" value="postgres"/>
      <property name="User" value="postgres"/>
      <property name="serverName" value="postgres-machine-name"/>
      <property name="DatabaseName" value="test"/>
    </jdbc-connection-pool>
...
    </resources>

I have copied the postgres client jar -
"postgresql-8.2dev-500.jdbc3.jar" into the application server lib
directory and restarted the machine.

The server works correctly i.e it connects to the database and also
creates the tables with the correct database field types.

Thanks
Pramod
 


Dmitry Mozheyko wrote:
> -----Original Message-----
> From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
> To: persistence_at_glassfish.dev.java.net
> Date: Mon, 20 Mar 2006 10:33:46 -0800
> Subject: Re: How to change SQL-statements for Persistence Unit
>
>
>> Hi Dmitry
>> What is your "jdbc/PostgreSQL" jdbc resource pointing too ?
>>
>
> PostgreSQLPool - no special information about Postgres.
> Filled properties:
> ServerName
> PortNumber
> DatabaseName
> user
> password
> defaultAutoCommit
>
>
>> I am interested to know the jdbc connection pool that is referenced by
>> this jdbc/PostgreSQL resource. We use the jdbc connection information to
>> to autodetect the database platform. Based on the error messages that
>> you have reported it seems that the jdbc resource is not currently
>> pointing to postgresql. Hence the datatypes that are created are wrong
>> and that eventually leads to the error that is being reported from the
>> database.
>>
>> The jdbc connection pool + jdbc resource should be configured to
>> correctly point to the database and then everything should properly. At
>> this point of time there are no known issues in this area.
>>
>> Thanks
>> Pramod
>>
>>
>> Sanjeeb Kumar Sahoo wrote:
>>
>>> Hi Dmitry,
>>>
>>> Your persistence.xml looks perfect.
>>>
>>> Pramod,
>>> Is Dmitry's issue a known issue?
>>>
>>> Thanks,
>>> Sahoo
>>> Dmitry Mozheyko wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
>>>> To: persistence_at_glassfish.dev.java.net
>>>> Date: Fri, 17 Mar 2006 17:49:48 +0530
>>>> Subject: Re: How to change SQL-statements for Persistence Unit
>>>>
>>>>
>>>>
>>>>
>>>>> Dmitry Mozheyko wrote:
>>>>>
>>>>>
>>>>>
>>>>>>> Did you specify any platform in you persistence.xml? The code
>>>>>>> tries to autodetect the database type, but if you specify it
>>>>>>> explicitly, your
>>>>>>> value will be used instead.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Where i can find docs, examples about this file?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> https://glassfish.dev.java.net/javaee5/persistence/entity-persistence-support.html#persistence.xml
>>>>>
>>>>>
>>>>> Can you send contents of your persistence.xml? Ideally, you don't
>>>>> have to use any special property to inform the runtime that you are
>>>>> using Postgress. It should be automatically detected for you.
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>>
>>>>>
>>>>>
>>>> Content of my persistence.xml:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <persistence xmlns="http://java.sun.com/xml/ns/persistence">
>>>> <persistence-unit name="em" transaction-type="JTA">
>>>> <jta-data-source>jdbc/PostgreSQL</jta-data-source>
>>>> <properties>
>>>> <property name="ddl-generation" value="createtables"/>
>>>> </properties>
>>>> </persistence-unit>
>>>> </persistence>
>>>>
>>>> "jdbc/PostgreSQL" - jndi name of my jdbc-resource.
>>>>
>>>> Thanks, Dmitry
>>>>
>>>>
>>>>