Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added info for multiple model/data sources.

...

Some WebObjects engineers use the setConnectionDictionary(...) method on a model to set the JDBC database connection parameters for the model. However, the servlet container has it's own data source mechanism for supplying database information which will override any connection dictionary information which is set into the model. If you don't want this to happen, and you want your setConnectionDictionary(...) to take effect, comment out the resource-ref item with the title jdbc/DefaultDataSource in the web.xml.template file.

If you have more than one data source Resource defined in either your WEB-INF/web.xml or in your META-INF/Context.xml file, WebObjects will complain about there being more than one configuration with this error:

An exception occurred while trying to open a channel: com.webobjects.jdbcadaptor.JDBCAdaptorException: Found multiple data sources. Please map the EOModels to a data source explicitly!

You must set the name parameter of each data source Resource in the web.xml/Context.xml with the same name as your eomodel file. For example:

EOModel name: MyModel.eomodel

data source Resource definition:

Code Block

  <Resource
	auth="Container"
	description="MyApp Data Source"
HERE -> name="MyModel"
	type="javax.sql.DataSource"
	driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
	url="jdbc:microsoft:sqlserver://serveraddress:1433;databaseName=TEST"
	username="user"
	password="pass"
	maxActive="4"
	maxWait="5000"
	maxIdle="10"
  />

Serving WebServerResources

...