Sunday Dec 06, 2015

Using a container datasource in Tomcat with MapViewer 12.2.1

Using a container data source in MapViewer (12.2.1) deployed on  Tomcat requires a modification to the usual process of defining a JNDI resource in Tomcat. To get the container datasource to work with MapViewer you need to prefix the string "java:comp/env/" to the container_ds name in the <map_data_source> entry in mapViewerConfig.xml.

That is, your entry should look like:

  <map_data_source name="mvdemo_container_ds"
                   container_ds="java:comp/env/jdbc/mvdemo"
                   number_of_mappers="4"
                   allow_jdbc_theme_based_foi="false"
                   editable="false"
   />

Do this after following the standard steps for defining a JNDI resource in Tomcat which uses the Oracle JDBC driver. That is,

  • the Oracle jdbc driver related classes (e.g. ojdbc6-12.10.jar, ora18n-12.1.0.jar) should be in TOMCAT_HOME/lib
  • Add the resource description to MapViewer's context.xml, i.e. mapviewer_home/META-INF/context.xml should contain an entry similar to:
    <Resource name="jdbc/mvdemo"
               auth="Container"
               type="javax.sql.DataSource"
               driverClassName="oracle.jdbc.OracleDriver"
                url="jdbc:oracle:thin:@host:port:SID"
               username="mvdemo"
               password="pwd4mvdemo"
              validationQuery="SELECT 1 FROM DUAL"
              validationInterval="30000"
              timeBetweenEvictionRunsMillis="30000"
              maxActive="100"
              minIdle="10"
              maxIdle="100"
              maxWait="10000"
              initialSize="10"
              removeAbandonedTimeout="60"
              removeAbandoned="true"
              logAbandoned="true"
             accessToUnderlyingConnectionAllowed="true"
        />

     

  • Add the resource description to MapViewer's web/xml (mapviewer_home/WEB-INF/web.xml). It should be similar to:
    <resource-ref>
     <description>Oracle Datasource example</description>
     <res-ref-name>jdbc/mvdemo</res-ref-name>
     <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
     <res-auth>Container</res-auth>
    </resource-ref>

Monday Jul 22, 2013

Connecting to a 12c database instance with MapViewer 11.1.1.7.x

The the jdbc connection string (or jdbc url) for a 12c database now requires a service name instead of a SID.

In MapViewer 11.1.1.7.1 the jdbc info in the map_data_source element in the mapviewer configuration file accepts a service name but requires a different syntax. The relevant details (from the README) are

MapViewer native (non-container) data sources can now use database service name in place of SID. 
To supply a db service name, you will use the same jdbc_sid attribute, but specify the service name 
with double slashes in front, e.g.:

  <map_data_source name="myds"
    jdbc_host="foo.com" 
    jdbc_sid="//mypdb1.foo.com" 
    jdbc_port="1522" 
    ... ...
  />

If you're using 11.1.1.7.0 then you need to use a container data source to connect to a 12c instance.

i.e. instead of using

<map_data_source name="my_12c_test"

                   jdbc_host="mydbinstance"
                   jdbc_sid="//pdborcl12c.foo.com"
                   jdbc_port="1522"
                   jdbc_user="mytestuser"
                   jdbc_password="m2E7T48U3LfRjKwR0YFETQcjNb4gCMLG8/X0KWjO00Q="
                   jdbc_mode="thin"
                   number_of_mappers="6"
                   allow_jdbc_theme_based_foi="false"
                   editable="false"
   />
use
  <map_data_source name="my_12c_test"
                   container_ds="jdbc/db12c"
                   number_of_mappers="6"
                   allow_jdbc_theme_based_foi="false"
                   editable="false"
   />

In my case the Glassfish 3.1.2.2 JDBC connection pool definition was:
Property
url  jdbc:oracle:thin:@mydbinstance:1522/pdborcl12c.rest_of.service.name

Uncheck the Wrap JDBC Objects option in Advanced panel, i.e. the Edit JDBC Connection Pool Advanced properties page.
Add a JDBC resource for that newly created pool and use that in mapviewerconfig.xml as above

About

Official blog for Oracle Maps and related products.

Search

Categories
Archives
« August 2016
SunMonTueWedThuFriSat
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   
       
Today