Link to home
Start Free TrialLog in
Avatar of Dreamn3d
Dreamn3d

asked on

WebSphere Studio / App Server share jndi connection

Hi All,
  I have an Application Server (5.1 running on SuSe Ent9 Linux) and I would like to access the jndi connections I have setup on the server via Studio.  Is this possible? If so, how can I define the jndi connection to the server?  

I have the client currently setup to run on the local workstation, but in order to use the jndi connections (via a vpn to our customer), the app has to run on the server.  Is there any way to use the jdbc connection that resides on the server?  I have seen some examples of specifing a jndi connection (jdbc::mysql-host:3306/dbconn) but so far, none of these have worked.

Thanks,
Jess
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

Hello Jess,

Do you mean that you configure jdbc connection pool on the server and you want to use connection by looking via jndi from your work station, right? If so, you can use InitialContext class to look up jndi on the server.

Here is some useful link

http://www.webspherepower.com/issuesprint/issue200410/00001357.html
Avatar of Dreamn3d
Dreamn3d

ASKER

Hi,
  Thanks for posting.  I had actually already seen this article and it discusses using a connection on the server when the application is running on the server, which is not what I need.  I need to be able to run the app on my (or other developers) workstation in the local 5.1 test environment, but use the jndi connection that the server provides.  

Unfortunately, the server is the only machine allowed to connect to a customers network via vpn, which is of course why this is needed.

Any ideas?

Thanks again!,
Jess  
Hello Jess,

Sorry for last comment which cannot help you. Please try this sample code, it shows you how to specify provider url and how to authenticate to get datasource.

Hashtable env = new Hashtable();
String dbUserName = "someID";
String dbPassword = "somePWD";


env.put (INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "iiop://[172.25.40.128:900");

Context ctx = new InitialContext(env);
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/nuu");
return ds.getConnection(dbUserName, dbPassword);


Hope this help,

SOMPOL
Hi,
  We are still trying to get your code to work.  It seems to start but the SequeLink driver is having issues, so I will let you know something soon (hopefully later today).  

Thanks again,
Jess
Hi,
  So far, none of this has worked.  We spoke with the client and got them to give each developer access via the vpn, and are now trying to pursue that avenue instead of sharing the jndi connection via the server, although I'm sure that there should be some way to get it to work.

I will award partial credit since you did try to help though.  Do you know how to do this?  Seems like in the old days, I would have to post a new question, and then accept your answer there.

Thanks again,
Jess
ASKER CERTIFIED SOLUTION
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial