Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

CSV files provide (Comma separated Text file) provides an easy way of storing simple tabular data. The sample csv file used in this example is hosted by USGS, the science organization which hosts latest earthquake information in CSV files online.

Follow the instructions below to create a data service using a sample CSV file as the data source.

You can find the sample CSV file we discuss here in here: DSS_HOME/samples/resources/Products.csv. It contains information on products manufactured in an automobile company. The sample table has ID, Name, Classification and Price as columns.

First, copy the JDBC driver to:

  • DSS_HOME/repository/components/lib directory
  • DSS_HOME/repository/components/dropins

For example, cp mysql-connector-java-5.XX-bin.jar /home/user/wso2ds/wso2-dataservices-XX/repository/components/lib. 

1. Log on to the Data Services Server Management Console.

2. Click the "Main" tab and select the " Create " link under " Data Services."

3. The "Create Data Service " page appears. Fill in the fields and click " Next." The Data Service name is mandatory.

Info

Info:
For more information on Advanced Configurations in creating data services, refer to the Transaction Handling section.

4. The " Data Sources " page appears. Click on the " Add New Data Source" link and add your Data Source details. Select the data source type as CSV.

Then click " Save."

For a RDBMS data source, select the data source type as RDBMS. We use a MySQL database as an example.example,

Info

Note:

Before saving, you can click on the 'Test Connection' button. If the database connection is successful, you will get the following message:

Image Removed

We use a sample file hosted online but you can also use one in your local machine.

Column Separator Values

  • Single Character = "X" (X is any character), e.g. ","
  • Tab = "\t"
  • Space = "\s"
  • Any Unicode Character = "\uXXXX" (XXXX is the hexadecimal unicode value)
    5. After saving, the added data source page appears. You can edit or delete the Data Source. To proceed click

...

  • Next.

...

6. The "Queries" page appears.

...