glassfish
  1. glassfish
  2. GLASSFISH-465

POSTGRESQL : The java.lang.Byte datatype when used produces an error

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

    • Issuezilla Id:
      465

      Description

      Currently the java.lang.Byte datatype has issue when used and the tests pass
      only when using the patch provided by Pramod and Mitesh, otherwise it fails
      with an exception. Attaching the email thread for reference.

      --------------------------------------

      Hi Sailaja
      This is a bug in the postgresql jdbc driver, when we try to do a
      preparedStatement.setObject() for a Byte parameter value. Have tried a simple
      jdbc program to confirm this. Also tried the latest postgresql jdbc driver
      (postgresql-8.2dev-501.jdbc3.jar) and the behavior is the same.

      With Mitesh's help have a patch that we would like you to test against
      PostgreSQL database. Also ensure that you are dealing with all the datatypes to
      confirm that this works properly. Also ensure that this jar is placed in
      the "classpath-prefix".

      Thanks
      Pramod

      --------------------------------------------------------------
      Output of the simple jdbc program ::
      > java cp .:/home/pramodg/jdbcClientFiles/postgresql-8.2dev
      501.jdbc3.jar:/home/pramodg/jdbcClient Files/derbyclient.jar PostgresClient
      SQLException : org.postgresql.util.PSQLException: Can't infer the SQL type to
      use for an instance o f java.lang.Byte. Use setObject() with an explicit Types
      value to specify the type to use.
      org.postgresql.util.PSQLException: Can't infer the SQL type to use for an
      instance of java.lang.Byt e. Use setObject() with an explicit Types value to
      specify the type to use.
      at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject
      (AbstractJdbc2Statement.java:1717)
      at PostgresClient.insertQuery(PostgresClient.java:197)
      at PostgresClient.main(PostgresClient.java:99)

      Sailaja Rao wrote:

      > Attaching the server.log file for a complete trace.
      >
      > -Sailaja
      >
      >
      > Mitesh Meswani wrote:
      >
      >> Hi Sailaja,
      >>
      >> Could you please post the complete stack trace.
      >>
      >> Thanks,
      >> Mitesh
      >>
      >> Sailaja Rao wrote:
      >>
      >>> Hi,
      >>>
      >>> What should the corresponding datatype for java.lang.Byte should be in
      postgresql ? Java2DB is currently mapping it to SMALLINT and it is also failing
      with the following exception. Please let me know.
      >>>
      >>> Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL
      type to use for an instance of java.lang.Byte. Use setObject() with an explicit
      Types value to specify the type to use.Error Code: 0
      >>>
      >>> Call:INSERT INTO DATATYPES (ID, BOOLEANDATA, CHARACTERDATA, SHORTDATA,
      UTILDATEDATA, INTEGERDATA, SQLDATEDATA, LONGDATA, FLOATDATA, BYTEDATA,
      TIMESTAMPDATA) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      >>>
      >>> Thanks,
      >>> Sailaja

      1. ejb-cmp-datatypesApp.ear
        101 kB
        sailajar
      2. server.log
        42 kB
        sailajar
      3. server.log
        42 kB
        sailajar

        Activity

        Hide
        sailajar added a comment -

        Created an attachment (id=170)
        Attaching server.log for complete stack trace

        Show
        sailajar added a comment - Created an attachment (id=170) Attaching server.log for complete stack trace
        Hide
        sailajar added a comment -

        Created an attachment (id=171)
        Attaching server.log for complete stack trace

        Show
        sailajar added a comment - Created an attachment (id=171) Attaching server.log for complete stack trace
        Hide
        sailajar added a comment -

        Steps to reproduce the problem.

        1) Deploy the attached ear file
        2) Create the following entries in domain.xml
        3) Run the Appclient to see the errors in server.log

        Entries in domain.xml

        <jdbc-resource enabled="true" jndi-name="jdbc/datatype1" object-type="user"
        pool-name="datatype-pool1"/>

        <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="true" max-pool-size="32" max-wait-time-in-
        millis="60000" name="datatype-pool1" non-transactional-connections="false" pool-
        resize-quantity="2" res-type="javax.sql.DataSource" steady-pool-size="8">
        <property name="User" value="dbuser"/>
        <property name="Password" value="dbpassword"/>
        <property name="user" value="dbuser"/>
        <property name="password" value="dbpassword"/>
        <property name="url"
        value="jdbc:postgresql://coresqe1.sfbay.sun.com/test:5432"/>
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="databaseName" value="test"/>
        <property name="serverName" value="coresqe1.sfbay.sun.com"/>
        </jdbc-connection-pool>

        <resource-ref enabled="true" ref="jdbc/datatype1"/>

        Show
        sailajar added a comment - Steps to reproduce the problem. 1) Deploy the attached ear file 2) Create the following entries in domain.xml 3) Run the Appclient to see the errors in server.log Entries in domain.xml <jdbc-resource enabled="true" jndi-name="jdbc/datatype1" object-type="user" pool-name="datatype-pool1"/> <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="true" max-pool-size="32" max-wait-time-in- millis="60000" name="datatype-pool1" non-transactional-connections="false" pool- resize-quantity="2" res-type="javax.sql.DataSource" steady-pool-size="8"> <property name="User" value="dbuser"/> <property name="Password" value="dbpassword"/> <property name="user" value="dbuser"/> <property name="password" value="dbpassword"/> <property name="url" value="jdbc:postgresql://coresqe1.sfbay.sun.com/test:5432"/> <property name="driverClassName" value="org.postgresql.Driver"/> <property name="databaseName" value="test"/> <property name="serverName" value="coresqe1.sfbay.sun.com"/> </jdbc-connection-pool> <resource-ref enabled="true" ref="jdbc/datatype1"/>
        Hide
        marina vatkina added a comment -

        Pramod is working on this

        Show
        marina vatkina added a comment - Pramod is working on this
        Hide
        sailajar added a comment -

        Created an attachment (id=172)
        testcase attachment

        Show
        sailajar added a comment - Created an attachment (id=172) testcase attachment
        Hide
        pramodgo added a comment -

        Have sent code changes for review.

        Show
        pramodgo added a comment - Have sent code changes for review.
        Hide
        pramodgo added a comment -

        Have checked in the changes.

        Show
        pramodgo added a comment - Have checked in the changes.

          People

          • Assignee:
            pramodgo
            Reporter:
            sailajar
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: