473,654 Members | 3,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding to JNDI datasource - please help

Hi all, I'm relatively new to JNDI concepts and need some help. I am
writing a web app that accepts a variable specifying a jndi pooled
connection datasource as a url variable. This is a requirement and
cannot be changed. For example index.jsp?db=ja va:defaultdb

How do I use this JNDI name to create a connection? All the
literature I have read says to bind the resource manager connection
factory reference (res-ref-name) to the (jndi-name) in the server
specific xml (assumes knowledge of jndi name beforehand). Then do a
lookup on res-ref-name. In this case I do not know on what server
this war will be deployed and want to bind directly to the datasource
defined by my url variable. Can I do this without using a
res-ref-name and doing a lookup?

Your help is apprecitated,

John
Jul 18 '05 #1
1 4080
John Chambers wrote:
Hi all, I'm relatively new to JNDI concepts and need some help. I am
writing a web app that accepts a variable specifying a jndi pooled
connection datasource as a url variable. This is a requirement and
cannot be changed. For example index.jsp?db=ja va:defaultdb

How do I use this JNDI name to create a connection? All the
literature I have read says to bind the resource manager connection
factory reference (res-ref-name) to the (jndi-name) in the server
specific xml (assumes knowledge of jndi name beforehand). Then do a
lookup on res-ref-name. In this case I do not know on what server
this war will be deployed and want to bind directly to the datasource
defined by my url variable. Can I do this without using a
res-ref-name and doing a lookup?


Yes. The res-ref-name and friends are there to allow the application
developer to use a specific (logical) JNDI location without knowing the
actual JNDI location. Then the application deployer binds the logical
JNDI location to a physical JNDI location.

But nothing prevents you from accessing the physical JNDI location
directly, except for following good programming practices. ;-)

Just give it a try and see what happens.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6259
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action pointing to "loginValidate.jsp" * a loginValidate.jsp page that references logic to validate requests * a loginBean class used to pass info between the JSP and validation logic * a usersDAO class used to perform lookups in a USERS
2
4440
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a problem with defining my JDBC resource within Tomcat. I am pretty sure that my code is correct (but I am not certain), and the problem is with defining the resource in Tomcat. Has anyone done this before? Any advice would be helpful.
1
25435
by: Kent | last post by:
I'm running on Win2000 and JRE 1.4.1.... I've got a small client trying to do get an InitialContext() and talk to the local JBoss server running on same machine (different VM of course). When I run the client using the -D parameters to specify the JNDI properties, it works fine. Example command line:
1
6200
by: slurper | last post by:
i have problems understanding jndi. i'm this far: i deployed the sun application server and i'm working through the examples (Duke bookstore, ...). Sometimes i see code which does a lookup to a JNDI-name like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/BookDB"); con = ds.getConnection();
0
5403
by: no-spam | last post by:
Hello group, I have some questions concerning configuring and using a JNDI DataSource with PostgreSQL and Apache Tomcat. Currently, I belive I have successfully configured a "basic" DataSource. Currently, my configuration which resides in a context.xml file is as follows: <Context className="org.apache.catalina.core.StandardContext" backgroundProcessorDelay="-1" cachingAllowed="true"
4
1951
by: Brian Conway | last post by:
I need some help on binding a datareader to a dropdown box. I have included the code for the dropdown below. It builds with no errors, but returns no results. Any help would be appreciated. private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { OleDbConnection conn = new OleDbConnection("DataSource=ntdrp001.world;
5
4219
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
0
2038
by: choukse | last post by:
Hi All, I am trying to bind to ADAM instance with a windows user through JNDI and it keeps failing. My ADAM and AD is running on same Windows 2k3 server. But, through LDP I am able to bind with the same windows user successfully and browse through the entire tree successfully. The error is as below
9
2651
dmjpro
by: dmjpro | last post by:
I thought that when the connection gets closed then all resources get closed . I also included the ResultSet and Statement ;) . But if the Statement closed then only ResultSet closed. But now i got the point ..after closing Connection i am still able to access to iterate the ResultSet . Actually it is tested only with Postgres. Is it sun specified : ? Now i tested another code ... import...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.