| Author |
Access Datasouce in java main method
|
ravisha andar
Ranch Hand
Joined: Feb 25, 2011
Posts: 55
|
|
Hi,
I have a datasource configured in my server(WebSphere).
Is it possible to use that datasource in my main method and run it as a java application.
Thanks.
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
|
It is advised to use an enterprise bean to access the database from client applications (link).
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
ravisha andar
Ranch Hand
Joined: Feb 25, 2011
Posts: 55
|
|
Hi
Thanks for the post.
But I do not want to run my application on the server. I want to run it as a java application ( in the main(String[] args) method
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
But I do not want to run my application on the server. I want to run it as a java application ( in the main(String[] args) method
You may need to access the data base directly with DriverManager JDBC API then.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26157
|
|
|
The datasource runs on the server. You can't access it from a standalone program outside the container.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
SreeHarsha Kotturu
Greenhorn
Joined: Dec 04, 2011
Posts: 4
|
|
Hi ,
I tried in the following way to get connection object of Oracle XE 10g through Data source configured in my Web sphere server .
If this helps try to use this.
|
 |
Piyush Mangal
Ranch Hand
Joined: Jan 22, 2007
Posts: 196
|
|
Jeanne Boyarsky wrote:The datasource runs on the server. You can't access it from a standalone program outside the container.
This is incorrect. DataSource can be bound to JNDI server through Application Server and can then be accessed from any java client through JNDI API.
|
 |
SreeHarsha Kotturu
Greenhorn
Joined: Dec 04, 2011
Posts: 4
|
|
I tried it worked. If it helps try to use it. I had a similar question, is not able to hit a webservice from a standalone java program?
|
 |
 |
|
|
subject: Access Datasouce in java main method
|
|
|