jndi « DataSource « Java Database Q&A





1. "java:comp/env/jdbc/MY_SQL_DS" or "MY_SQL_DS" or what else to reference the DataSource from within Java?    stackoverflow.com

"java:comp/env/jdbc/MY_SQL_DS" does not work. I get a Naming Exception: NameNotFoundException. neither works "MY_SQL_DS" alone.name exception again. I created another JNDI for a Mail Session named "MY_MailSession" and reference it like (javax.mail.Session) ctx.lookup( ...

2. What are the major motivations to use JNDI for datasources?    stackoverflow.com

I fail to understand why someone would use JNDI. Can someone high light the major reasons to use JNDI for datasources?

3. JNDI Path for JDBC data sources?    stackoverflow.com

I sometimes see JDBC data sources specified in JNDI that use the "jdbc" path. For example, the following (for Tomcat6):

<Resource name="jdbc/myAppDS" auth="Container" type="javax.sql.DataSource"
       ..... ...

4. Is it safe to cache DataSource lookups in JEE?    stackoverflow.com

I'm developing a simple Java EE 5 "routing" application. Different messages from a MQ queue are first transformed and then, according to the value of a certain field, stored in different ...

5. Why use JNDI for data sources    stackoverflow.com

Can anyone help explain why JNDI should be a preferred way to expose services such as a database / jms? The posts I run into all talk about the advantage of not ...

6. Using a JNDI datasource can I get the connection string from it?    stackoverflow.com

I have my application on Tomcat with a JNDI datasource. I need to access the connection string from it. Is there a way to do that in my application?

7. How to let non-web components access J2EE JNDI Datasources?    coderanch.com

Originally posted by Steven Ostrowski: Hello everyone! I'm trying to use the JNDI server that is in the J2EE server, but I'm trying to access it from a separate Java application. In particular, I'm trying to use the Datasource method of retrieving a connection. Basically what I want to do is be able to administratively add a Datasource like you do ...

8. using the RMI registry for accessing a DataSource via JNDI ?    coderanch.com

okay, but is there a handy way to store objects in a jndi context, even if I don't use the RMI registry or an LDAP or name service ? I know JNDI only provides a common interface for all these types of services, but I'm looking for a simple implementation so I can use JNDI to store and retrieve objects, only ...

9. JNDI : how to create and get Data source ?    coderanch.com

Hello All, I want to know how to create data source and how to use it ? i need complete tutorial.if any one having link or documentation please give me. Actually i want to use connection pooling in my web project. i am using tomcat as web server with jsp and servlet.and sql server as data base Thanks, Vijay Saraf. [ ...





10. DataSource naming convention using JNDI    coderanch.com

11. question about jndi for datasource    coderanch.com

12. DataSource and JNDI    coderanch.com

public static void main (String args []) throws SQLException { // Create a OracleDataSource instance explicitly OracleDataSource ods = new OracleDataSource(); // Set the user name, password, driver type and network protocol ods.setUser("scott"); ods.setPassword("tiger"); ods.setDriverType("oci8"); ods.setNetworkProtocol("ipc"); // Retrieve a connection Connection conn = ods.getConnection(); getUserName(conn); // Close the connection conn.close(); conn = null; }

13. datasource jndi cast error. help!    coderanch.com

14. JNDI LOOK up problem for datasource    coderanch.com

Hi Jeanne Thanks for responding. What line of code throws the exception? DataSource ds = (DataSource)ctx.lookup("sbcdatasource"); It says classcastexception. Well if u says there is problem in look up name, if i print the Object ds = ctx.lookup("sbcdatasource"); System.out.println("ds ::: " + ds); It gives me all the information abt the Datasource, shown below is the o/p ds ::: Reference Class ...





17. Using DataSource object with JNDI    coderanch.com

Hi, I am working on this exercise and would be thankful if somebody could point me in the right direction to tackle it. Create a servlet that displays a list of customers (From the customer table of the database). Use the HTML table to organize the display. Hint: Use a Java Bean, e.g. CustomerBean that has the fields of First Name, ...

18. Registering a DataSource in JNDI    coderanch.com

I'm struggling like mad setting up test cases for a web application I'm trying to test using JUnit. To briefly describe the setup: we have a number of possible data servers, all defined in jndi-definitions.xml and loaded into JNDI on web-app start up. Our DB class takes an argument to the constructor: the name of the server to use and does ...

19. is this Mandatory to define DataSources(JNDI ref) in Application Descriptor of WAS 5.0 prior to use?    coderanch.com

Hi All, is this Mandatory to define DataSources(JNDI ref) in Application Descriptor of WAS 5.0 prior to use? i just want to change the lookup of JNDI names to global name space, i don't want to define the datasources in web.xml. Right now my application lookup of JNDI Name's will have "java:env...../jdbc/someName". But i want to avoid "java:env..." to lookup at ...

20. JDBC,JNDI,DataSource    coderanch.com

JDBC is slight similar to JNDI because they are both OO Java API. The JNDI is mostly used for accessing a native interface while the JDBC is more on relational database. You can use JDBC without JNDI or you can use both. Based on your question, the JNDI, JDBC and DataSource can be used together for a purpose. Based on my ...

21. Query in : JNDI look up of DataSource    coderanch.com

22. Query related to JNDI datasource    coderanch.com

Hi I am using apache common DBCP for connectiion pooling in tomcat. I am working on a web application. Following is the lookup code:- initContext=new InitialContext(); ds=(DataSource) initContext.lookup("java:comp/env/jdbc/yourrail"); con=ds.getConnection(); if(initContext!=null) initContext.close(); Every time, when i need a connection object, i am always executing the above code(lookung up for datasource in JNDI tree). My Question is:- (1)I have a servlet as a ...

23. Can JNDI store a datasource? It is supposed to...    forums.oracle.com

Context.PROVIDER_URL is the url of the JNDI provider url not the jdbc connection string. Context.INITIAL_CONTEXT_FACTORY is the initial context factory class name not the jdbc driver class name. Take a look at the jndi examples for your application server! If you are running inside the app server you probobally just need to use Context context = new InitialContext();