This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 152739 - error accessing the postgresql database
Summary: error accessing the postgresql database
Status: RESOLVED INVALID
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: Other All
: P3 blocker (vote)
Assignee: Matthew Bohm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-07 22:25 UTC by bgk
Modified: 2009-09-18 16:03 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bgk 2008-11-07 22:25:32 UTC
I created a database link to a postgres database table and used those tables to create CRUD web application using  java
server faces option in Net Beans 6.5 via>

create entitie classess from database
Create JSF pages from entities

The application compiles ok and gets to index.html page showing the links to the tables. when u click on the links, it
tries to access the data base (postgres) and just keeps waiting. Checked the database etc is running. h

When I created the same tables in java database (bundled in NBeans) it works fine. 

The error appears to be in the auto generated connection link to postgres database which needs "" in between the
qualifiers "database name"."schema"."table name". The Netbeans does not seem to put those quotes and it just sits there
trying...

Here is the error:

  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
        at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b57-fcs (10/23/2008))):
oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "public.ent_clinic" does not exist
Error Code: 0
Call: SELECT COUNT(CLINIC_ID) FROM emrdev.public.ENT_CLINIC
Query: ReportQuery(entity.EntClinic)
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:566)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
        at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:473)
Comment 1 David Vancouvering 2008-11-07 22:41:03 UTC
Reassigning to persistence for evaluation.

You only need to quote the database identifiers if you quoted them when you created them.  If you don't quote when you
create, you shouldn't have to quote when you refer to the identifiers in your queries.  
Comment 2 Jan Horvath 2008-11-10 10:31:06 UTC
bgk, I was not able to reproduce the error described in this issue. Please attach the schema of your database and specify the postgres version.
Comment 3 bgk 2008-11-10 17:13:45 UTC
Postgres version is 8.2. and server is glassfish v2 on 
You can create any table in the database and try the default options for creating entities from table and then jsf from
the entity classes. 

eg: I created a table REF_GENDER as follows:

CREATE TABLE "REF_GENDER"
(
  "GENDER_CD" character varying(1) NOT NULL,
  "GENDER_DESCRIPTION" character varying(10),
  CONSTRAINT "REF_GENDER_PK" PRIMARY KEY ("GENDER_CD")
) 
WITHOUT OIDS;
ALTER TABLE "REF_GENDER" OWNER TO postgres;

Next I create a new web application > java server faces framework in netbeans
Click on the project name and select create entity classes from database
Select the appropriate db connection and select the table ENT_GENDER.
Selected persistence unit option.

The view the class is created fine.

Then select option to create jsf from entity classes for this class.
then build and run the application.

compile fine and displays the WelcomeJSF.Jsp page with hyperlink to the show all RefGender Items as follows. But when u
click on the hyperlink to see the gender items, it just shows the wait icon as when trying to retrieve data for the page.

"JavaServer Faces

Show All RefGender Items "


Here are the logs:

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
Created dir: C:\java\Test_Gender\build\web\WEB-INF\classes
Created dir: C:\java\Test_Gender\build\web\META-INF
Copying 1 file to C:\java\Test_Gender\build\web\META-INF
Created dir: C:\java\Test_Gender\build\web\WEB-INF\classes\META-INF
Copying 1 file to C:\java\Test_Gender\build\web\WEB-INF\classes\META-INF
Copying 12 files to C:\java\Test_Gender\build\web
library-inclusion-in-archive:
Copying 1 file to C:\java\Test_Gender\build\web\WEB-INF\lib
Copying 1 file to C:\java\Test_Gender\build\web\WEB-INF\lib
Copying 1 file to C:\java\Test_Gender\build\web\WEB-INF\lib
Copying 1 file to C:\java\Test_Gender\build\web\WEB-INF\lib
library-inclusion-in-manifest:
compile:
compile-jsps:
Created dir: C:\java\Test_Gender\dist
Building jar: C:\java\Test_Gender\dist\Test_Gender.war
In-place deployment at C:\java\Test_Gender\build\web
Start registering the project's server resources
Finished registering server resources
moduleID=Test_Gender
deployment started : 0%
deployment finished : 100%
Deploying application in domain completed successfully
Trying to create reference for application in target server  completed successfully
Trying to start application in target server  completed successfully
Deployment of application Test_Gender  completed successfully
Enable of Test_Gender in target server completed successfully
Enable of application in all targets  completed successfully
All operations completed successfully
run-deploy:
Browsing: http://localhost:8080/Test_Gender/
run-display-browser:
run:
BUILD SUCCESSFUL (total time: 1 minute 6 seconds)

LIST.jsp

accept	text/javascript, text/html, application/xml, text/xml, */*	Edit...
accept-language	en-us	Edit...
x-prototype-version	1.5.0_rc1	Edit...
referer	http://localhost:8080/Test_Gender/	Edit...
x-requested-with	XMLHttpRequest	Edit...
com.sun.faces.avatar.partial	true	Edit...
content-type	application/x-www-form-urlencoded	Edit...
accept-encoding	gzip, deflate	Edit...
user-agent	Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR
3.5.20404; .NET CLR 3.0.04506.648)	Edit...
host	localhost:8080	Edit...
content-length	1612	Edit...
connection	Keep-Alive	Edit...
cache-control	no-cache	Edit...
cookie	JSESSIONID=72a4c2ba303f80a477e60521ac88	Edit...
Comment 4 Matthew Bohm 2008-11-10 20:55:41 UTC
It's the persistence provider (toplink) that formulates the actual sql. I don't believe the netbeans-generated jpaql can
influence the resulting sql at that level, that is, with respect to quotation marks, etc. If it's an issue with
quotation marks, the solution, as davidvc discusses, may be to create the database without quotes.

Sorry to downgrade to P3, but we do not yet know that the IDE can control this. If it's truly something under IDE
control, we can always bump the priority up again.

bgk, can you create the database without quotes and retry?
Comment 5 bgk 2008-11-12 02:06:59 UTC
Hi,

I don't think it is problem with "" as I did not create the database with "" but used everything default- default
creation of table in postgres, default creation of entity classes from database in NB  and default creation of jsf pages
for the entity classes created (in net beans) but it give issue with accessing the list.jsp created.

Thanks,
bgk
Comment 6 Matthew Bohm 2008-11-20 01:50:05 UTC
bgk, thanks--but why do you have the quotes in your earlier note:

<snip>
eg: I created a table REF_GENDER as follows:

CREATE TABLE "REF_GENDER"
(
  "GENDER_CD" character varying(1) NOT NULL,
  "GENDER_DESCRIPTION" character varying(10),
  CONSTRAINT "REF_GENDER_PK" PRIMARY KEY ("GENDER_CD")
) 
WITHOUT OIDS;
ALTER TABLE "REF_GENDER" OWNER TO postgres;
</snip>

We'll need the database schema, postgres version, and possibly the project as attachments in order to investigate. Thanks!
Comment 7 bgk 2008-11-20 14:14:48 UTC
The output is default when the table name and columns are upper case. if you select a table in postgres and right click
to "create script" it generates this creation script for a table. Just used it for generating the table in postgres.
Comment 8 Matthew Bohm 2008-11-20 22:16:28 UTC
Right, so one thing to try might be tweaking the script (removing quotes) and regenerating your database schema from the
tweaked script. If it works, then we can be pretty certain about the cause.
Comment 9 bgk 2008-11-20 22:34:48 UTC
Thanks. It does appear to be the problem with the quotes that are automatically generated (I think when the names are
uppercase in tables) I created tables in lowercase and it does not have quotes and goes through without problems. That
proves the point that the " " placed by default by Postgres to represent upper case table/column names is the problem.
any suggestions (other than changing the table names (which may not be an option..as other application works) to fix the
issue?
Comment 10 Matthew Bohm 2008-11-20 22:54:49 UTC
Maybe try tweaking the script to use uppercase and without quotes, and then regenerate your database schema from the
newly tweaked script?
Comment 11 Martin Schovanek 2009-09-18 16:03:00 UTC
Without requested information for long time - INVALID. We can't do anything in this case. Reporter, please add requested
information and reopen issue. Thanks in advance.