Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get data source(websphere) in standalone application

 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any one knows how to get data source which is located in was 6.0 from a standalone application? What are the required jar files?
Currently I encounter such an exception:
Error in lookup a datasource :javax.naming.NamingException: Failed to initialize the ORB [Root exception is org.omg.CORBA.INITIALIZE: can't instantiate default ORB implementation com.ibm.rmi.iiop.ORB vmcid: 0x0 minor code: 0 completed: No]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataSources are only local. So you cannot do a remote lookup of a datasource.

Mark
 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why it is running well on weblogic application server? I'm puzzled by different app servers...
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really shouldn't, and even if it did. Doing a remote lookup to get a DataSource then using one of the connections from the connection pool, which means it has to be sent down to the client, isn't really a thing you want to do. If you have to have the client accessing the database directly, then just create a Connection on the client side.

Mark
 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for help!

Finally it works only after adding all jar files of was and jre (embedded in was), although not clear what is the accurate list of jar files since there are more than 200 jar files...

Otherwise, if
create a Connection on the client side

how to hide/encrypt user id/password in property file, and furthermore, it will be different in different stage(dev, sit, ...)?
 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Otherwise, I encounter a new problem when getting connection from data source:


Configuration:
WAS 6.0
have a Component-managed authentication alias and select it in data source(Test connection is ok)
the data source seems belong to the server (cell:node:server)
JDBC Implementation class name: oracle.jdbc.xa.client.OracleXADataSource

Pls note: calling dataSource.getConnection() has such problem (it is ok in weblogic), dataSource.getConnection("username", "password") is ok, but we don't want to hardcode them in source code.
Thanks in advance!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So my question still is why you want to have access to the DataSource and Connection on the client-side? Why even have a middle tier if you want the client to have direct access to the database?

Mark
 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The history is that we have a complete online application, and this standalone app one is the seperate part which will gather information from database scheduledly. The two ones are running on the same machine.

It has existed when I touched it, maybe its positive aspect is to hide username/password and control the total number of connections, but connection to db seperately should seems more clear structure and independent, but how to control the total number of connections since there is no pool. If there is some problem in scheduled job which will call standaline app, maybe there will be a lot of connections. I'm not clear about the balance, could you clarify your point of view about it? Thanks!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.

FIrst, there are connection pool apis out there. Look at C3PO as an example. It actually comes bundled with Hibernate for use in Stand-Alone applications. Hibernate requires there to be a connection pool.

Also, if it is a Stand-Alone application means to me at any point there can only be one user on the client side, so they only need one connection anyway. Now if there is some part that creates seperate threads and each one needs to talk to the database, then maybe, maybe then I can see using more than one connection at the same time. But I would question that architecture too.

Mark
 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thus, how about username and password? They seems have to be stored in property file rather than hardcoded in source code, but how to encryt, plain text seems not proper since they are confidential.
 
Michael Aillon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Server.....Regarding your post about "Otherwise, I encounter a new problem when getting connection from data source:". Did you ever find a solution? I have same exact problem. The funny thing is that I've configured this same data souce on many other machines and other server instances many times with out any issues. So I'm not a newbie at this. Any help would be appreciated. Thanks
 
manoj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have the same issue as yours with the username and password. Have you found a solution for this issue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic