[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1060
  • Last Modified:

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
0
Dreamn3d
Asked:
Dreamn3d
  • 3
  • 3
1 Solution
 
sompol_kiatkamolchaiCommented:
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
0
 
Dreamn3dAuthor Commented:
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  
0
 
sompol_kiatkamolchaiCommented:
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Dreamn3dAuthor Commented:
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
0
 
Dreamn3dAuthor Commented:
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
0
 
sompol_kiatkamolchaiCommented:
Thanks for your credit. :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now