• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jboss-Jndi-Datasource

 
Gangireddy Danam
Ranch Hand
Posts: 32
Java Redhat
  • Mark post as helpful
  • send pies
  • 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
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which version of JBoss AS?

Have you looked in the JBoss AS docs?
 
Gangireddy Danam
Ranch Hand
Posts: 32
Java Redhat
  • Mark post as helpful
  • send pies
  • 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.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Java Redhat
  • Mark post as helpful
  • send pies
  • 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
Java Redhat
  • Mark post as helpful
  • send pies
  • 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
Java Redhat
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic