aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Get data source(websphere) in standalone application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Get data source(websphere) in standalone application" Watch "Get data source(websphere) in standalone application" New topic
Author

Get data source(websphere) in standalone application

Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
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]


<i>Mike</i>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

DataSources are only local. So you cannot do a remote lookup of a datasource.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
But why it is running well on weblogic application server? I'm puzzled by different app servers...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

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

Joined: Jul 24, 2006
Posts: 56
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

Joined: Jul 24, 2006
Posts: 56
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

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

Joined: Jul 24, 2006
Posts: 56
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

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

Joined: Jul 24, 2006
Posts: 56
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

Joined: Jan 07, 2007
Posts: 5
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

Joined: Jun 24, 2002
Posts: 25
We have the same issue as yours with the username and password. Have you found a solution for this issue.
 
 
subject: Get data source(websphere) in standalone application