Background
In Java Studio Creator 2, to connect a Creator 2 web application to a database, a data source must be created first using the Add Data Source feature in the Server Navigator. Visual Web Pack (VWP) also uses data sources, however, data sources are generated automatically and unfortunately, there is no convenient way to name or rename a data source. See Renaming a Data Source entry.
In VWP, data sources are generated when a database table is dragged and dropped onto a VWP Page or component in a VWP Page (e.g. Page1 that is created when creating a new Visual Web application)
The name of the data source is generated automatically. To see the name of the data source generated, in the Outline, expand the SessionBean (or the bean in which the database table was dropped) and select a rowset node. Then check the Properties window for the data source property for the name.
Also, JDBC resources are created in the project under the setup folder. To view the resources for a project, with the project opened, switch to the Files tab and expand the setup folder then open the resources file. Resource files will have "extra properties" such as the connection info - username, driver name, database port number, etc.
The data source name must match the JNDI name created in the Application Server JDBC Resources, otherwise,
when executing an application an HTTP 500 error will occur.
A missing data connection means that the data source was not found in the IDE's context.xml and/or no NetBeans database connection and corresponding JDBC Driver reference exists.
Here, I'll describe how to import a project from Creator 2, another Visual Web Pack installation or restored the userdir. For users of the Technology Preview release, see the notes below. Also for more info,
there is a migration document available
VWP Final Release Information
Changes in the final release
- There is a new Help topic for Data Source References. When the Data Source References node is selected, type the F1 key, or search Help
- The project node is no longer badged and project name label does not change to red if there are
unresolved data source references. This change helps some with open-project-performance - There is a new Data Source References node and a child node for each Data Source . Expand the project's node to view.
- The Resolve Database Problems context menu has been replaced by Resolve Data Sources context menu located on the Data Source References node.
- If a data source is missing then a badge is pinned to the node representing the data source that is missing
Importing a Creator 2 database project
1. User has a database project developed in Java Studio Creator 2 Update 1 and wants to import this project in VWP, or
2. User has developed a new Visual Web database application that contains a rowsets. (if another user wants to use this project or the developer has restored the userdir, then the data sources will not be found)
Here's the steps required for both use cases to resolve missing data connections.
- Open the project
- (VWP Technology Preview Only)Project node icon will be badged, in the Projects window
- Right-click and select Resolve Database Problem to open a dialog listing the missing database connection(s)
- By selecting a Data Source name then clicking the Add connection button, the Add Database Connection dialog will open. Note, a connection has been preconfigured for Java DB, presuming Glassfish has been registered and the IDE has been restarted. If the IDE was not restarted then the user is required to navigate to the location of derbyclient.jar (%GLASSFISH_INSTALL_PATH%\javadb\lib),select the jar and continue with the following steps
- If the data source to resolve is to a Java DB database then fill in the username, password, JDBC URL and select a validation table.
- example: parameters for connecting to the Travel database
- User ID = travel
- Password = travel
- Database URL = jdbc:derby://localhost:1527/travel
- Next, click the Add button and you're done
- To resolve a database connection to another database server, the user can either click the Edit New
button or from the Server Type dropdown selectitem to add a new server type and make the driver jar available. This will open the Edit Database Server Types dialog
If resources (JNDI/connection pool) haven't been generated on the App Server and JNDI resources have not been added to a project (in the setup folder)
3. A project is opened and data sources have not been created in the context. Choosing to Resolve Data Source(s) adds data sources to the context, plus connection resources. If another project that uses the same data source is opened then previously, then select the Data Source References node, right-click and choose Resolve Data Source(s) . After a few seconds the data sources will be resolved and the project can be deployed
4. If a user cleans up the App Server by deleting domain1 or removing connections then by choosing to Resolve Data Sources, the connection resources are added to the project so it can be deployed successfully. After removing domain1 folder, use the command
ant -f setup.xmlto restore the user domain.
Notes
- Since Java DB is not bundled with VWP, when adding a new Connection, the user can navigate to the Derby installation diretory under Glassfish (javadb\lib) to add derbyclient.jar
- Open the project
- (VWP Technology Preview Only)Project node icon will be badged, in the Projects window
- Right-click and select Resolve Database Problem to open a dialog listing the missing database connection(s)
- By selecting a Data Source name then clicking the Add connection button, the Add Database Connection dialog will open. Note, a connection has been preconfigured for Java DB, presuming Glassfish has been registered and the IDE has been restarted. If the IDE was not restarted then the user is required to navigate to the location of derbyclient.jar (%GLASSFISH_INSTALL_PATH%\javadb\lib),select the jar and continue with the following steps
- If the data connection to resolve is to a Java DB database then fill in the username, password, JDBC URL and select a validation table.
- example: parameters for connecting to the Travel database
- User ID = travel
- Password = travel
- Database URL = jdbc:derby://localhost:1527/travel
- Next, click the Add button and you're done
Technology Preview Information
Importing a Creator 2 database project
1. User has a database project developed in Java Studio Creator 2 Update 1 and wants to import this project in VWP, or
2. User has developed a new Visual Web database application that contains a rowsets. (if another user wants to use this project or the developer has restored the userdir, then the data connections will not be found)
Here's the steps required for both use cases to resolve missing data connections.
- To resolve a database connection to another database server, the user can either click the Edit New
button or from the Server Type dropdown selectitem to add a new server type and make the driver jar available. This will open the Edit Database Server Types dialog
If resources (JNDI/connection pool) haven't been generated on the App Server and JNDI resources have not been added to a project (in the setup folder)
3. A project is opened and data sources have not been created in the context. Choosing to Resolve Database Problems adds data sources to the context, plus connection resources. If another project that uses the same data source is opened then previously, Resolve Database Problems won't add the connection resources to the project (this is fixed in the Final Release) *
4. If a user cleans up the App Server by deleting domain1 or removing connections then by choosing to Resolve Database Problems, the connection resources are added to the project so it can be deployed successfully. After removing domain1 folder, use the command
ant -f setup.xmlto restore the user domain.
Notes
- Since Java DB is not bundled with VWP, when adding a new Connection, the user can navigate to the Derby installation diretory under Glassfish (javadb\lib) to add derbyclient.jar
- * Bug (this is fixed in the Final Release)- if more than one project is opened and they use the same data source then data sources can be resolved for only the first project.
- To resolve data sources for each project
- Exit NetBeans
- Edit the context.xml file in the userdir (e.g. C:\Documents and Settings\< user >\.netbeans\5.5\context.xml and remove the entry surrounded by <object> </object> corresponding to the data source just added
- Restart NetBeans and then resolve the data sources for the other project

Posted by Pier on December 20, 2006 at 03:21 AM PST #
Posted by John Baker on December 20, 2006 at 10:04 PM PST #
Posted by 67.170.207.112 on December 20, 2006 at 10:12 PM PST #
Posted by Gilad on February 25, 2007 at 09:34 AM PST #
Posted by Win Pe on May 03, 2007 at 11:59 PM PDT #