This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes API's for creating data sources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "API Watch "API New topic
Author

API's for creating data sources

Maruti Nori
Greenhorn

Joined: Mar 13, 2002
Posts: 7
Hi,
In our current application we create datasources for Weblogic using installer, which writes entries into config.xml. Now in WebSphere we have a problem in this approach because the passwords are encrypted and stored in server-cfg.xml.Are there any API's exposed by IBM to perform this function in WebSphere.
regards,
Maruti Nori
Se Ravin
Greenhorn

Joined: Feb 18, 2002
Posts: 26
yes you can,
The following code (from coonection_pool.pdf ) for IBM WAS 4.0 does this,
import com.ibm.websphere.advanced.cm.factory.DataSourceFactory;
try {
//Create a properties file for the DataSource
java.util.Properties prop = new java.util.Properties();
prop.put(DataSourceFactory.NAME, "SampleDB");
prop.put(DataSourceFactory.DATASOURCE_CLASS_NAME,
"COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource");
prop.put(DataSourceFactory.DESCRIPTION, "My sample
datasource");
prop.put("databaseName", "sample");
//Obtain a DataSource from the factory
DataSource ds = DataSourceFactory.getDataSource(prop);
//Bind the DataSource into JNDI
DataSourceFactory.bindDataSource(ds);
} catch (ClassNotFoundException cnfe) {
//check the class path for all necessary classes
} catch (CMFactoryException cmfe) {
//Example of exception: incorrect properties
} catch (NamingException ne) {
//Example of exception:
//datasource by this name may already exist
}
Regards
Senthil


We are and We are Not
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: API's for creating data sources
 
Similar Threads
JMS without reference to EJB
i have a flex component and i want to write simple helloworld in that using java API's
Could not read configuration file [log4j.properties].
What is JDO?
problem with Struts app and RequestContextListener