jQuery in Action, 2nd edition*
The moose likes JBoss/WildFly and the fly likes Jboss-Jndi-Datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss-Jndi-Datasource" Watch "Jboss-Jndi-Datasource" New topic
Author

Jboss-Jndi-Datasource

Gangireddy Danam
Ranch Hand

Joined: Aug 08, 2012
Posts: 32

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
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Which version of JBoss AS?

Have you looked in the JBoss AS docs?


JBoss In Action
Gangireddy Danam
Ranch Hand

Joined: Aug 08, 2012
Posts: 32

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.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

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.

[My Blog] [JavaRanch Journal]
Gangireddy Danam
Ranch Hand

Joined: Aug 08, 2012
Posts: 32

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

Joined: Aug 08, 2012
Posts: 32

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

Joined: Aug 08, 2012
Posts: 32


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
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

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
 
jQuery in Action, 2nd edition
 
subject: Jboss-Jndi-Datasource