IMS-Society Forum Index IMS-Society
Forum for IMS
 
 FAQFAQ   SearchSearch   CalendarCalendar UsergroupsUsergroups  DownloadsDownloads   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IMS Universal JCA/JDBC driver problem

 
Post new topic   Reply to topic    IMS-Society Forum Index -> XML, XQUERY, JDBC, ODBA
View previous topic :: View next topic  
Author Message
agattu



Joined: 17 Feb 2009
Posts: 3
Location: Sweden

PostPosted: Fri Apr 09, 2010 6:32 am    Post subject: IMS Universal JCA/JDBC driver problem Reply with quote

Hi

I have done some test with IMS Open Database (one of our customers are very interested in using it) . First I tested it using the IMS Universal JDBC driver and it worked fine. Then I tried to use the resource adapter IMS Universal DB Resource Adapter with the IMS Universal JCA/JDBC driver (imsudbJLocal.rar) and then I get a problem.

After reading the manual (which is a little confusing in some parts) I used this code to get a datastore to work with.

Code:
InitialContext ic = new InitialContext();
ds = (DataSource)ic.lookup("java:comp/env/odbm01");

but when I run this code, I get this exception on the is.lookup statement

Quote:
java.lang.ClassCastException: com.ibm.ims.db.cci.ConnectionFactoryImpl incompatible with javax.sql.DataSource


I don’t understand why I get a ConnectionFactoryImpl and not a DataSource object like it is described in the manual. This I my main problem.

A secondary problem is sample code from the manual that I have been trying to follow:

Code:
//obtain the initial JNDI Naming context
InitialContext ic = new InitialContext();

//perform JNDI lookup to obtain the data source
javax.sql.DataSource ds =
 (DataSource)ic.lookup("java:comp/env/imsdblocal");

//specify connection properties
ds.setUser("myUserID");
ds.setPassword("myPassword");
props.put("sslConnection", "true");
props.put("loginTimeout", "10");

//create JDBC connection
java.sql.Connection con = ds.getConnection();

There is not setUser method on the DataSource class and how do I create the object props?

I’m running the code in a servlet in RDz 7.1.1

I appreciate any help I can get.

Thanks
Back to top
View user's profile Send private message
Thilo Liedloff
Expert


Joined: 16 Jul 2008
Posts: 3

PostPosted: Tue Apr 13, 2010 5:40 pm    Post subject: Re: IMS Universal JCA/JDBC driver problem Reply with quote

Hi,

the manual sadly contains some mistakes in the code sample.
I try to explain your options briefly.

1. Using DataSource Interface unmanaged

Code:

import java.sql.*;             
import javax.sql.*;           
import com.ibm.ims.jdbc.*; 

Connection conn = null;

IMSDataSource ds = new com.ibm.ims.jdbc.IMSDataSource();

ds.setMetadataURL("class://BMP255.BMP255DatabaseView");                   
ds.setDatastoreName("IMS1");
ds.setDatastoreServer("host.com");                         
ds.setPortNumber(5555);     
ds.setDriverType(4);
ds.setSSLConnection("false");
ds.setLoginTimeout("10");
ds.setUser("myUserID");     
ds.setPassword("myPassword");
conn = ds.getConnection();


2. Create the DriverManager Interface unmanaged
Code:

Properties props = new java.util.Properties();   
props.put( "user", "MyUserID" );       
props.put( "password", "MyPassword" ); 
String url =
"jdbc:ims://host.com:5555/class://BMP2.BMP2DatabaseView";
Connection conn = DriverManager.getConnection(url, props);


3. Using a JNDI managed DataSource

You can try to cast an IMSDataSource like
Code:

IMSDataSource ds = (IMSDataSource)ic.lookup(...);
ds.setUser(...);
ds.setPassword(...);
conn =ds.getConnection();


or you can use the standard JDBC approach when you want just to edit user and pw.
Code:

DataSource ds = (DataSource)ic.lookup(...);
conn =ds.getConnection(username,password);


I don't see at the moment why the ClassCast Error occurs. Maybe you can try to install the IMS Universal JDBC Resource Adapter not as J2C Connection Factory but as DataSource in your Application Server like a DB2 Driver. Alternativly you can try to work with the ConnectionFactory and get a Connection from there.
But I hope the samples above will help you to solve the other problems.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IMS-Society Forum Index -> XML, XQUERY, JDBC, ODBA All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP