aspose file tools*
The moose likes JDBC and the fly likes Access Datasouce in java main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Access Datasouce in java main method" Watch "Access Datasouce in java main method" New topic
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: 3775

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: 3775

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: 29249
    
139

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?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Datasouce in java main method
 
Similar Threads
datasource jndi cast error. help!
datasource jndi cast error
Share information between Web App and Stand-alone Java App
How to set up DataSource in plain Java application?
Query reg Tomcat connection pool