Netbeans persistence.xml - definition of path for persistence unit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Netbeans persistence.xml - definition of path for persistence unit

dawp
I have an application that connects to a Derby database using the Derby Network Server that has been started as a standalone process outside of the Netbeans IDE.

When I run my application within the IDE (I don't start the Network Server from the Services tab as it is already running) the following is observed:-

The application connects successfully to the server.
Subsequent database accesses fail with error Internal Exception: java.sql.SQLNonTransientConnectionException: The connection was refused because the database MyAppDB was not found.
Error Code: 40000
The persistence.xml in Netbeans shows the following for the JDBC connection:- jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB [david on TEST]

However the xml source in Netbeans shows the following:- jdbc:derby://localhost:1527/MyAppDB

I can fix this problem by changing the persistence.xml source (in Netbeans) to show the following for JDBC connection:-

jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB

Everything now works and the application runs fine :-)

HOWEVER!!!

As soon as I tell Netbeans to do a Clean and Build Project, it reverts the JDBC connection back to:-

jdbc:derby://localhost:1527/MyAppDB

On running the Application it can no longer access the Db with the same error as above.

Note that none of these problems occur if I run the Network Server from with Netbeans by opening the connection via the Services tab. This is no good for me as I want to deploy the application.

Do any of you guys know what is going on here? - I'm sure it's a simple mistake on my part.

Thank you.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Netbeans persistence.xml - definition of path for persistence unit

markwade
Try adding:

-J-Dderby.system.home=C:/Users/David/Desktop/DerbyDatabases/

to the end of netbeans_default_options in netbeans.conf in the etc
directory of your NetBeans installation.


On 03/26/2017 06:18 PM, dawp wrote:

> I have an application that connects to a Derby database using the Derby Network Server that has been started as a standalone process outside of the Netbeans IDE.
>
> When I run my application within the IDE (I don't start the Network Server from the Services tab as it is already running) the following is observed:-
>
> The application connects successfully to the server.
> Subsequent database accesses fail with error Internal Exception: java.sql.SQLNonTransientConnectionException: The connection was refused because the database MyAppDB was not found.
> Error Code: 40000
> The persistence.xml in Netbeans shows the following for the JDBC connection:- jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB [david on TEST]
>
> However the xml source in Netbeans shows the following:- jdbc:derby://localhost:1527/MyAppDB
>
> I can fix this problem by changing the persistence.xml source (in Netbeans) to show the following for JDBC connection:-
>
> jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB
>
> Everything now works and the application runs fine :-)
>
> HOWEVER!!!
>
> As soon as I tell Netbeans to do a Clean and Build Project, it reverts the JDBC connection back to:-
>
> jdbc:derby://localhost:1527/MyAppDB
>
> On running the Application it can no longer access the Db with the same error as above.
>
> Note that none of these problems occur if I run the Network Server from with Netbeans by opening the connection via the Services tab. This is no good for me as I want to deploy the application.
>
> Do any of you guys know what is going on here? - I'm sure it's a simple mistake on my part.
>
> Thank you.
>
>
>
>
>

Loading...