## org.apache.mahout.cf.taste.impl.model.jdbc
Class SQL92JDBCDataModel

    java.lang.Object
      org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
          org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
              org.apache.mahout.cf.taste.impl.model.jdbc.SQL92JDBCDataModel

All Implemented Interfaces:
  Serializable, Refreshable, DataModel, JDBCDataModel

Direct Known Subclasses:
  PostgreSQLJDBCDataModel

    public class SQL92JDBCDataModel

extends AbstractJDBCDataModel

A `JDBCDataModel` backed by a SQL92 compatible database and accessed via JDBC. It should work with most JDBC databases, although not optimized for performance. By default, this class assumes that there is a `DataSource` available under the JNDI name "jdbc/taste", which gives access to a database with a "taste_preferences" table with the following schema:

     CREATE TABLE taste_preferences (
       user_id BIGINT NOT NULL,
       item_id BIGINT NOT NULL,
       preference REAL NOT NULL,
       PRIMARY KEY (user_id, item_id)
     )
     CREATE INDEX taste_preferences_user_id_index ON taste_preferences (user_id);
     CREATE INDEX taste_preferences_item_id_index ON taste_preferences (item_id);

See Also:
  `SQL92BooleanPrefJDBCDataModel`, Serialized Form

Field Summary

Fields inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
`DEFAULT_ITEM_ID_COLUMN, DEFAULT_PREFERENCE_COLUMN, DEFAULT_PREFERENCE_TABLE, DEFAULT_PREFERENCE_TIME_COLUMN, DEFAULT_USER_ID_COLUMN`

Fields inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
`DEFAULT_DATASOURCE_NAME`

Constructor Summary
`SQL92JDBCDataModel()` Creates a using the default `DataSource` (named `AbstractJDBCComponent.DEFAULT_DATASOURCE_NAME` and default table/column names.
`SQL92JDBCDataModel(DataSource dataSource)` Creates a using the given `DataSource` and default table/column names.
`SQL92JDBCDataModel(DataSource dataSource, String preferenceTable, String userIDColumn, String itemIDColumn, String preferenceColumn, String timestampColumn)` Creates a using the given `DataSource` and default table/column names.
`SQL92JDBCDataModel(String dataSourceName)` Creates a using the default `DataSource` found under the given name, and using default table/column names.

Method Summary
`protected String` `getUpdatePreferenceSQL()`
`protected String` `getVerifyPreferenceSQL()`
`void` `setPreference(long userID, long itemID, float value)` Override since SQL92 doesn't have the same non-standard capability that MySQL has, to optionally insert or update in one statement.

Methods inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel

`buildPreference, doGetPreferencesForItem, exportWithIDsOnly, exportWithPrefs, getDataSource, getItemIDColumn, getItemIDs, getItemIDsFromUser, getLongColumn, getMaxPreference, getMinPreference, getNumItems, getNumUsers, getNumUsersWithPreferenceFor, getNumUsersWithPreferenceFor, getPreferenceColumn, getPreferencesForItem, getPreferencesFromUser, getPreferenceTable, getPreferenceTime, getPreferenceValue, getUserIDColumn, getUserIDs, hasPreferenceValues, refresh, removePreference, setLongParameter`

Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
`checkNotNullAndLog, checkNotNullAndLog, getFetchSize, lookupDataSource`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SQL92JDBCDataModel

    public SQL92JDBCDataModel()
                       throws TasteException

  Creates a using the default `DataSource` (named `AbstractJDBCComponent.DEFAULT_DATASOURCE_NAME` and default table/column names.

  Throws:
    `TasteException` - if `DataSource` can't be found

### SQL92JDBCDataModel

    public SQL92JDBCDataModel(String dataSourceName)
                       throws TasteException

  Creates a using the default `DataSource` found under the given name, and using default table/column names.

  Parameters:
    `dataSourceName` - name of `DataSource` to look up
  Throws:
    `TasteException` - if `DataSource` can't be found

### SQL92JDBCDataModel

    public SQL92JDBCDataModel(DataSource dataSource)

  Creates a using the given `DataSource` and default table/column names.

  Parameters:
    `dataSource` - `DataSource` to use

### SQL92JDBCDataModel

    public SQL92JDBCDataModel(DataSource dataSource,
                              String preferenceTable,
                              String userIDColumn,
                              String itemIDColumn,
                              String preferenceColumn,
                              String timestampColumn)

  Creates a using the given `DataSource` and default table/column names.

  Parameters:
    `dataSource` - `DataSource` to use
    `preferenceTable` - name of table containing preference data
    `userIDColumn` - user ID column name
    `itemIDColumn` - item ID column name
    `preferenceColumn` - preference column name
    `timestampColumn` - timestamp column name (may be null)

Method Detail

### getUpdatePreferenceSQL

    protected String getUpdatePreferenceSQL()

### getVerifyPreferenceSQL

    protected String getVerifyPreferenceSQL()

### setPreference

    public void setPreference(long userID,
                              long itemID,
                              float value)
                       throws TasteException

  Override since SQL92 doesn't have the same non-standard capability that MySQL has, to optionally insert or update in one statement.

  Specified by:
    `setPreference` in interface `DataModel`
  Overrides:
    `setPreference` in class `AbstractJDBCDataModel`
  Throws:
    `TasteException`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.