Generic JDBC X/Y Database Table

Example

Named table resources can point to a generic XY table in a JDBC datasource. This is an example of a named table definition for a database table with X/Y geometry columns. This uses the DBDataSourceMetadata element to specify the X and Y geometry columns defined in the database table. The X/Y database table is not expected to have a geometry column.

In this example, the database connection definition to a X/Y table in Oracle is defined using the following tokens. The connection could also be defined as a named connection instead of inline.

  • @owner@ the owner name of the Oracle table
  • @host@ the host name used to connect to the Oracle database
  • @port@ the port number used to connect to the Oracle database
  • @SID@ the SID for the Oracle instance
  • @username@ the user credentials for accessing the database
  • @password@ the password credentials for accessing the database

It defines a DBDataSourceMetadata element indicating the name of the geometry X and Y columns.

  • @srsname@ the name of the coordinate system for the X and Y columns in the table
  • @x_attribute@ the name of an attribute containing the X Coordinate
  • @y_attribute@ the name of an attribute containing the Y Coordinate
<?xml version="1.0" encoding="UTF-8"?>
<NamedDataSourceDefinition version="MXP_WorkSpace_1_5">
	<DBConnection dbType="oracle">
        <ConnectionName>/myOracleConnection</ConnectionName>
        <JDBCDriverParameters>
            <JDBCUrl>jdbc:oracle:thin:scott/tiger@localhost:1521:MyDB</JDBCUrl>
            <DriverPropertySet>
                <Property name="user" value="scott"></Property>
                <Property name="password" value="tiger"></Property>
            </DriverPropertySet>
        </JDBCDriverParameters>
    </DBConnection>
	<DataSourceDefinitionSet>
		<DBDataSourceDefinition id="ora1">
			<DataSourceName>oracle1</DataSourceName>
			<DBTable owner="@owner@" useQuotes="true">table1</DBTable>
			<DBDataSourceMetadata>
				<FeatureXYAttributes srsName="@srsname@">
					<XAttribute>@x_attribute@</XAttribute>
					<YAttribute>@y_attribute@</YAttribute>
				</FeatureXYAttributes>
			</DBDataSourceMetadata>        
		</DBDataSourceDefinition>
	</DataSourceDefinitionSet>
	<DataSourceRef ref="ora1"/>
</NamedDataSourceDefinition>

Style an X/Y Table

In the X/Y table, it is also possible to add a style to the X/Y table features, either by specifying an existing style column in the table, or define an inline style in the named table.

If the X/Y table has a column which contains the styles per row, it can be used by adding a FeatureStyleAttribute element to the DBDataSourceMetadata element. In the X/Y table example, you would add the FeatureStyleAttribute to the DBDataSourceMetadata, where: @STYLE_ATTRIBUTE@ is the name of the column containing the per row style for the feature.

<DBDataSourceMetadata>
	<FeatureXYAttributes srsName="@srsName@">
		<XAttribute>@X_ATTRIBUTE@</XAttribute>
		<YAttribute>@Y_ATTRIBUTE@</YAttribute>
	</FeatureXYAttributes>
	<FeatureStyleAttribute type="mapbasic">@STYLE_ATTRIBUTE@</FeatureStyleAttribute>
</DBDataSourceMetadata>

If the X/Y table does not have a column that contains the styles per row, you can use an inline style definition by adding a FeatureStyle element to the DBDataSourceMetadata element. You can use any type of supported FeatureStyle for the X/Y table. For example, you could add a PointStyle to the X/Y feature attributes, where:

  • @font_name@ the name of the font family for the font symbol (e.g., MapInfo Real Estate)
  • @font_size@ the size to be used for the font symbol (e.g., 14)
  • @size_unit@ the unit in which the @font_size@ is defined (e.g., mapinfo:length pt)
  • @stroke@ the color for the font symbol (e.g., blue)
  • @opacity@ the opacity for the font symbol (e.g., 1)
  • @font_char@ the character to be used for the font symbol when rendering the corresponding character from @font_name@ (e.g., A)
<DBDataSourceMetadata>
	<FeatureXYAttributes srsName="@srsName@">
		<XAttribute>@X_ATTRIBUTE@</XAttribute>
		<YAttribute>@Y_ATTRIBUTE@</YAttribute>
	</FeatureXYAttributes>
	<FeatureStyle>
		<PointStyle>
			<FontSymbol family="@font_name@" size="@font_size@" size-unit="@size_unit@" stroke="@stroke@" stroke-opacity="@opacity@" text="@font_char@"/>
		</PointStyle>
	</FeatureStyle>
</DBDataSourceMetadata>