Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Datasouce in java main method

 
ravisha andar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is advised to use an enterprise bean to access the database from client applications (link).
 
ravisha andar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The datasource runs on the server. You can't access it from a standalone program outside the container.
 
SreeHarsha Kotturu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic