Creating and Editing Data Adapters
Creating a Data Adapter
You create data adapters using the Data Adapter Wizard. The exact steps and information you need to provide vary with the type of adapter that you select. However, the initial steps are similar.
Data adapters can be created locally in projects or globally in the Repository Explorer.
| • | Data adapters in projects are stored as XML files, which simplifies deployment to JasperReports Server. A project-level data adapter cannot be seen from other projects, but you can easily copy it from one project to another. |
| • | Global data adapters are saved as Eclipse settings and are visible to all projects. Global data adapters are saved as Eclipse settings. To deploy a global adapter to JasperReports Server, you need to export it to an XML file located in the same project as your report. |
To create a data adapter in a project:
When you create a data adapter in a project, it is saved as an XML file in that project. Saving the XML file in the same project as your reports makes it easier to deploy the data adapter to JasperReports Server.
| 1. | Click ![jss-icon-new-data-adapter.png.8b07cd23f1cc500ab0234c9fa5177e72.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
| 2. | In the DataAdapter File window, choose the project where you want to save the data adapter file. This should be the project that contains the report(s) you want to use with your data adapter. |
| 3. | Enter a name for your adapter and click Next. |
The Data Adapters Wizard opens.
![dataadapter-wizard.png.0e5e51d9aadef48abace57b19fe18958.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Data Adapter Wizard |
| 4. | Select the data adapter type you want and click Next. |
| 5. | Enter a name for your adapter. This name is used when you select an adapter for a report. |
| 6. | Enter the properties needed by the adapter type you selected. For example, for a database JDBC connection you need to select a JDBC driver and set the URL and database username and password. For a CSV file, you need to enter a filename, column names, and the column separator. |
| 7. | (Optional) If you want to test the connection, click the Test button if available. |
| 8. | Click Finish to create the adapter. |
The adapter is saved as an XML file in the project location you selected.
To create a global data adapter:
When you create a global data adapter, it is available to all reports. However, if you want to deploy it to JasperReports Server, you must export it explicitly.
| 1. | Click ![jss-icon-new-data-adapter.png.211bfb9bc86a91fc951182850d500874.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
The Data Adapters Wizard opens.
| 2. | Select the data adapter type you want and click Next. |
| 3. | Enter a name for your adapter and the properties needed by the adapter type you selected. To optionally test the adapter, click the Test button. |
| 4. | Click Finish to create the adapter. |
Importing and Exporting Data Adapters
Jaspersoft Studio enables you to import and export data adapter definitions to simplify the process of sharing data source configurations.
To export a global data adapter as an XML file:
| 1. | In the Repository Explorer, right-click your data adapter and select Export to File. |
Jaspersoft Studio prompts you to name the file and select the destination for the exported information.
Export to File Dialog |
![export-data-adapter.png.fdcf2fa5bcc6b215651dae0a5ca399c0.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
| 2. | Select a location in the same project as the report that will be using this adapter, enter a name for the file, and click OK. |
A simple XML file is created in the location you chose. The data adapter must be in the same project as your report. To use the same adapter in more than one project, see Copying a Data Adapter.
To promote a data adapter file to a global data adapter:
You can make any file-based data adapter into a global adapter by importing it.
| 1. | Right-click on the Data Adapter node in the Repository Explorer, and choose Import from Workspace. |
| 2. | Select the data adapter(s) you want to import. |
| 3. | You can optionally select Overwrite Data Adapter if exists. Otherwise, if a duplicate data source name is found during the import, Jaspersoft Studio appends a number to the imported data source name. |
The import process adds all the selected data adapters to the current list.
Copying a Data Adapter
If you have saved your data adapter as an XML file, you can easily copy it between projects.
To copy a data adapter from one project to another:
| 1. | In the Project Explorer, right-click your data adapter and select Copy OR use Ctrl-C. |
| 2. | Still in the Project Explorer, right-click the project or folder in your Jaspersoft Studio workspace that you want to use and select Paste OR Ctrl-V. |
The data adapter is copied to the new location.
Recommended Comments
There are no comments to display.