JavaBlog.fr / Java.lu Documentum,ECM,TOOLS DCTM Documentum : DataSource Configuration (DS)

Documentum : DataSource Configuration (DS)

Hi,

Juste a mini-post concerning the configuation of DATASOURCE on Documentum server.
The DATASOURCE (DS) are configurable:

 
Here, the example for the DS “java:/MY_ARCHIVE_DS” :

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
    <profile>
       <subsystem xmlns="urn:jboss:domain:datasources:1.0">

            <datasources>

                <datasource jndi-name="java:/MY_ARCHIVE_DS" pool-name="MY_ARCHIVE_DS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MYDBSERVER123)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MYARCHIVE)))</connection-url>
                    <driver>oracle.jdbc</driver>
                    <pool>
                        <min-pool-size>5</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                    </pool>
                    <security>
                        <user-name>MY_APP_USER</user-name>
                        <password>WD{HUO/dfdfdsfdsfh]-DUHi</password>
                    </security>
                    <validation>
                        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
                    </validation>
                </datasource>
	        <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="oracle.jdbc" module="oracle.jdbc">
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>
                    <driver name="sqljdbc" module="com.microsoft.sqlserver">
                        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>
    </profile>

    <interfaces>

    </interfaces>

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

    </socket-binding-group>
</server>

 
 
The use of this DS in the JOB/JAVA code could be:

	private static final String DS = "MY_ARCHIVE_DS";
	private static final String JNDI_PREFIX[] = { "java:/", "java:", "jdbc/" };

	//...
		InitialContext ic = new InitialContext();
		for (int i = 0; i < JNDI_PREFIX.length && dataSource == null; i++) {
			try {
				dataSource = (DataSource) ic.lookup(JNDI_PREFIX[i] + DS);
			} catch (NamingException e) {
			}
		}
		if (dataSource == null) {
			throw new Exception("Unable to find datasource " + DS);
		}
	//...

	Connection connection = dataSource.getConnection();
	try {
		connection.setAutoCommit(false);

		PreparedStatement statement = connection.prepareStatement(MessageFormat.format(sql.toString(), StringUtils.upperCase(StringUtils.trimToEmpty(table)), year.format(coll.getTime("time_stamp").getDate())));

		//... Save the original data in a BLOB field in ARCHIVE database
		Blob blob = connection.createBlob();

		//...
		statement.executeUpdate();

		//...
		blob.free();

		//...
		statement.close();

		//...

	} finally {

		if(connection!=null){
	
			if (commit) {
				connection.commit();
				println("SqlConnection transaction commited !");
			} else {
				connection.rollback();
				println("SqlConnection transaction rollbacked !");
			}
			connection.close();
		}
	}

That’s all!!!

Huseyin OZVEREN

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post