Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jboss-Jndi-Datasource

 
Ranch Hand
Posts: 32
Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to add datasource object with jndi name to the jndi tree view of jboss server ?

how to utilize this object in the java program with lookup method ?

if i specifies the datasource name is name in *-ds.xml file.
example: with intialcontext.lookup("name"); or with intialcontext.lookup(java:/name"); ?

if any java example application available to utilize Jboss related datasource object please refer here ?

Thanks&Regards
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which version of JBoss AS?

Have you looked in the JBoss AS docs?
 
Gangireddy Danam
Ranch Hand
Posts: 32
Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for late reply...i am using Jboss 5.1.x .
In this Datasource usage object is giving erros . Could please tell me how to use the binded object with naming convention into java program with simple code,,

Thanks & Regards
Gangireddy.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the relevant datasource configurations, the exception stacktraces and the relevant code where you are using this datasource.

P.S: While posting code, logs and xml content, please wrap them in a code block for better formatting.
 
Gangireddy Danam
Ranch Hand
Posts: 32
Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i had placed this xml file in deploy folder.





The java program which uses the above jndi name is as follows.





when i was running the above program followed error is getting.







 
Gangireddy Danam
Ranch Hand
Posts: 32
Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gangireddy Danam wrote:i had placed this xml file in deploy folder.







The java program which uses the above jndi name is as follows.





when i was running the above program followed error is getting.







 
Gangireddy Danam
Ranch Hand
Posts: 32
Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Could you please see the above posted code and let me know the reason , why i am not able to get connection to the Database ..?

Thanks&Regards
Gangireddy
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the root cause:

Caused by: java.net.UnknownHostException: MySqlDS

Which means that code is assuming that MySqlDS is a host name.

You are using a stand-alone client to access a data source from the server, which is a practice hat is frowned upon. While it is possible, it is not recommended. When using a remote JNDI lookup, you don't use the "java:" prefix. Thus line 21 should read:

DataSource ds=(DataSource)ic.lookup("MySqlDS");

In addition, you need to add "<use-java-context>false</use-java-context>" to your *-ds.xml file. See this: http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/beta500/html/ch13s15.html
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic