Jndi connection

Hi all,
im trying to check the status of db through JNDI name for datasource, i created datasource in weblogic server console and trying to get status through simple java application.
here is the code i used
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup(jndiname);
Connection con = ds.getConnection();
con.setAutoCommit(false);
con.close();
please help me
im getting following exception
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
Thanks;
rahul
Edited by: user13310774 on Jun 22, 2010 4:09 AM
Edited by: user13310774 on Jun 22, 2010 4:13 AM

Hi,
if you are using this code for obtaining JNDI from a client (not on the server), you should indeed initialize JNDI environment like this:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "...");
Context context = new InitialContext(env);
See how to do it and more details here: http://download.oracle.com/docs/cd/A97688_16/generic.903/a97690/jndi.htm
Hope that helps,
Ivaylo

Similar Messages

  • How to setup BPEL JNDI connection on the application server

    Hi
    Can anyone tell me how to write a JNDI connection for my BPEL process? Currently we are invoking all my BPEL processes from a property file, but i need to call my BPEL process thru JNDI connection. Is it possible? If yes then How?
    Has anyone got any idea? Please let me know
    BTW, you need more clarification on the question, let me know please.
    Thanks.
    Deepak

    Hi Grafl,
    Chk this link
    Folder creation in AL11 using ABAP program
    try this code.This works on UNIX servers
    data: unixcom like   rlgrap-filename.
    data: begin of tabl occurs 500,       
            line(400),    
          end of tabl.
    dir = unixcom = 'mkdir mydir'. "command to create dir
    "to execute the unix command 
    call 'SYSTEM' id 'COMMAND' field unixcom
                      id 'TAB' field tabl[].
    <b>Reward Points if Useful</b>
    Regards
    Gokul

  • JNDI connection error - page not rendered properly

    Dear All.
    Always when I go to my application url I have er: "JBO-26061: Error while opening JDBC connection"
    and a page is displayed only partially (not fully rendered).
    In my case i have 5 development enviroments where I'm deploying my application.
    On 3 envs app works prefectly but on 2 not. The only main difference (that i found) between thoese
    servers is a timezone. Env: 1,2,3 has GMT+1 last two GMT. I didn't set up those machines, but from
    far as I was told, configuration is the same. Weblogic version: 10.3.6.0
    Does anybody now how to fix it? Before I will change a time, I would like to get familiar if a time difference could be an issue.
    Regards.
    Robert.
    supposed error in log:
    [ServletContext@556457299[app:iPlatform_v module:app_v.01-ViewController-context-root path:/app_v.01-ViewController-context-root spec-version:2.5]] Servlet failed with Exception
    oracle.jbo.DMLException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-26061.
    at oracle.jbo.server.DBTransactionImpl.establishNewConnection(DBTransactionImpl.java:1034)
    at oracle.jbo.server.DBTransactionImpl.initTransaction(DBTransactionImpl.java:1174)
    at oracle.jbo.server.DBTransactionImpl.initTxn(DBTransactionImpl.java:6826)
    at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:304)
    at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:335)...
    Edited by: user623575 on 20-Jun-2012 01:30

    update:
    always when I run my application in weblogic console (Summary of JDBC Data Sources->Monitoring) JDBC DataSource Runtime Statistics show
    state overloaded.
    Active Connections Average Count, Active Connections Current Count, Active Connections High Count = 15.
    I receive this information only on 2 enviroments from 5. Strange case because JNDI connection is configuret exactly the same.
    Any solutions guys?
    Regards.

  • Crystal Reports 2008 - Eclipse and JNDI connection.

    I am evaluting Crystal Reports 2008 .
    I want to use JNDI connection that is defined within my app server by Crystal reports so that I'll have better control of the properties defined.
    How do I set up JNDI data source connection in Crystal Reports 2008 ?
    I defined the following parameters u2026
                    JNDI Provider URL : jnp://localhost:1099
                    Initla Context as :  org.jnp.interfaces.NamingContextFactory
    And user name / password  as defined in JBoss setup
    I also have  u201Cjboss\client\jbossall-client.jaru201D in the classpath .     
    But I am getting Cannot instantiate class exception .
    Thanks in Advance for the help.

    Mr. Ted, We can expose JNDI connections from the appserver. Infact the database connection pool resoures are exposed as JNDI resources, JMS factory and connections are exposed as JNDI etc.
    In fact, JNDI is a means of securely exposing the resources managed by the app server to be used by trusted clients.
    We have achieved this on weblogic (8.1 - JDK 1.4.2) but we would like to replicate the same in glassfish app server ver 3.1.2 and would require the proper factory placed inside the rpt as well as the CRConfig.xml.
    Otherwise, (if we are using conventional URL string) when we ship the rpt files, we need to place this only as localhost. This mandates the presence of rpt files to be in the same server as database server and database. We want to avaoid this by creating a JNDI and use that database access resource inside the rpt files.

  • CR4E - New JDBC (JNDI) connection at runtime

    Is it possible to create a new JDBC (JNDI) connection at runtime using the propertyBag to set the attributes?  I tried this but received error message stating "error finding jndi name".

    Are you specifying a JDBC or JNDI connection?
    If JDBC, did you set the (Optional) JNDI Connection property?
    If you set the JNDI property for the JDBC connection, it'll try connecting to the JNDI.
    The JDBC has the optional JNDI property, so that you can design a report against JDBC, then use the JNDI when deployed to a J2EE.
    Sincerely,
    Ted Ueda

  • TOMCAT 5.0  - JNDI Connection Fails

    Hey guys,!
    Just wanted to test a JNDI datasource I created through the Tomcat administrator with a simple code in a Servlet, here's the snipped code:
                   System.out.println("Starting initial context");
                   Context initCtx = new InitialContext();
                   Context envCtx = (Context) initCtx.lookup("java:comp/env");
                   DataSource ds = (DataSource)
                   envCtx.lookup("jdbc/OFI4");
                   Connection conn = ds.getConnection();
                   //... use this connection to access the database ...
                   conn.close();
    The thing is, I'm getting an error that I've google for the las couple of days and have not found any helpful answers about it, the error message is:
    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
         at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
         at test2.doGet(test2.java:68)
    Caused by: java.sql.SQLException: No suitable driver
         at java.sql.DriverManager.getDriver(DriverManager.java:243)
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
    thank u people, any hel will be greatly appreciated.!
    Regards,
    Esteban

    Hey guys....!
    I figured out the way to make the JNDI connection work and I can tell you, it DOES work. Apparently, there are some troubles when creating the JNDI datasource by using the Tomcat Administration tool.
    Follow this steps to sort this issue out:
    1. Delete any of the datasources u've created by using the Tomcat Administrator make sure that no tags regarding these datasources remains in the server.xml file
    2. Include the Resource tag in your application web.xml, as follows:
         <resource-ref>
         <description>DB Connection</description>
    <res-ref-name>jdbc/OFICDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
         </resource-ref>
    3. Create a xml file named exact as your application (i.e app1, testApp...) and place it at CATALINAHOME/conf/Catalina/localhost. The document content must be as the following (please note that you must change values such as database name, username, password). This files is associated to an application called testCR3
    <?xml version='1.0' encoding='utf-8'?>
    <Context path="/testCR3" docBase="testCR3" debug="5" reloadable="true" crossContext="true" workDir="work\Catalina\localhost\testCR3">>
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_textCR3_log." suffix=".txt" timestamp="true"/>
    <Resource name="jdbc/OFICDB" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/OFICDB">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@12.145.12.134:1521:OFICDB</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>user1value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>pwd1</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>-1</value>
    </parameter>
    </ResourceParams>
    </Context>
    If u have any additional troubles, do not hesitate to let me know.
    Best regards,
    E10
    Message was edited by:
    E10

  • A bug in creator when creating jdbc jndi connection

    Hi,
    I am using sun java studio creator for jdbc jndi connection. The syntax is
    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mydb");
    conn = ds.getConnection();
    It's failed. Once I change to ctx.lookup("jdbc/mydb") and the connection is created.
    Once deployed to tomcat, it seems only java:comp/env/jdbc/mydb is working.
    The full path(java:comp/env/jdbc/mydb) seems right from my google search.
    Why creator using jdbc/mydb? Is it a bug to creator?
    Thanks,
    Jie

    I mean a resource reference in web.xml file that looks like this:
         <resource-ref id="ResourceRef_1103225373500">
              <res-ref-name>DBConnection</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Application</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>
    where DBConnection is the resource alias I mentioned before:
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/DBConnection");
    Using WebSphere a binding between this above defined ResourceRef and JNDI mapping must be defined in a file called ibm-web-bnd.xmi. The content of this file will look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1" virtualHostName="default_host">
    <webapp href="WEB-INF/web.xml#WebApp"/>
    <resRefBindings xmi:id="ResourceRefBinding_1103225373500" jndiName="jdbc/mydb">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1103225373500"/>
    </resRefBindings>
    </webappbnd:WebAppBinding>
    Obviously using WSAD all of that could be done using IDE. In your case and using Sun IDE, I am not sure. But this is basically the concept of needed mapping in order to reference your JNDI without getting an error. At least this is how we resolved the error you are encountering.
    Hope that helps!

  • How to configure jdbc/jndi connection in crystal report 10

    Post Author: effy
    CA Forum: Data Connectivity and SQL
    i have tried to configure jdbc/jndi connection , i have both
    drivers  data base side and  crystal report side but i
    can't  configure it.  so please help if u know
    something. 

    Sorry, but I'm not on a home pc, I'm working on a virtualized pc with a long chain of permissions ... so I cannot simply download and run an utility...
    Instead... I think (I WAS thinking) someone from SAP can tell me this info ... Probably I'll buy a paid assistance ticket... But really it's a strange thing that a simply connection from a (so) paid software need a so difficult problem solving routine..
    I edited my environment variales: JAVA, PATH; CLASSPATH; JAVA_DIR, and a long list of others ... to ALL point to ALL of directory containing used jars...
    .. I asked my SysAdmin to edit CrConfig.xml and it's done ... classpath are rights, jdbc infos are also ok, ...
    .. but none ...

  • Please Help.  How can you monitor a directory using jndi connection to a ldap server?

    How can you monitor a directory using jndi connection to a ldap server? I
    want the ldap server to monitor the content change in a file system
    directory on another computer on the network. Can someone please help.
    Thanks
    Fred

    Hi,
    Why do you want to use LDAP for Hard disk monitoring..???
    U can do this by creating a MD5 checksum for all the files existing in some
    perticular
    directory and every hour or any configurable period u can recalculate the
    checksum
    to find out the change in the content.
    I guess all u need is to get the code for "updatedb" utility of Linux and
    instrument it for ur needs..
    Hope it helps...
    -aseem
    mr wrote:
    How can you monitor a directory using jndi connection to a ldap server? I
    want the ldap server to monitor the content change in a file system
    directory on another computer on the network. Can someone please help.
    Thanks
    Fred

  • Failover and Load Balancing with JNDI Connection Pools

    Hi,
    I am trying to figure out how would JNDI Connection Pooling work along with failover or DNS Load Balancing.
    Would connections be distributed equally among the list?
    Would the pool work with multiple heterogeneous connections (i.e. connections to different but equivalent servers ), or do all the connections in the pool have to be homogeneous (i.e. to the same server)?
    Thanks,
    Sergio

    Hi,
    I am trying to figure out how would JNDI Connection Pooling work along with failover or DNS Load Balancing.
    Would connections be distributed equally among the list?
    Would the pool work with multiple heterogeneous connections (i.e. connections to different but equivalent servers ), or do all the connections in the pool have to be homogeneous (i.e. to the same server)?
    Thanks,
    Sergio

  • How do we create a jndi connection in crystal reports XI

    how do we create a jndi connection in crystal reports XI when the data soiurce is configured on websphere 6.1

    You need to use WLST online. I am not sure what your exact requirements are but one good way of working this is to have a WLST script that deletes all your WL customisations, like connection pools, JMS Servers etc and then creates it. That way you can run the same script repeatedly and it will get everything up to date for you. However you have to remember that everytime you add something new you need to update your delete section. Also your deleting should not fail if the item does not exist. I hope that makes sense!
    As to the specifics of WLST examples to do this then check out the WLST examples in CodeShare.
    If you are still having issues then post another message.
    Geoff

  • Different weblogic JNDI Connections sharing the same dbms session

    Hi,
    we have setup JDBC Datasource on the weblogic server. Creating connection using JNDI lookup is sharing the same session across different connections, which is causing invalid data generation in global temp tables. The data in the global temp table is accessed accross db sessions.
    I have created a test case, using JDBC connection, the global temp table data is not accessible across session (this is correct behavior).
    where as using JNDI connection the data from the temp table is accessed across different connections. (This is not expected behavior)
    I tried setting statement cache = 0, Remove Infected Connections Enabled = true / false but no use.
    is there any other setup in the weblogic to avoid db session sharing across connections??
    Thank you,
    Ranga

    I am using a single thread, This can be easily reproducible on any machines.
    @ Sequence to follow
    @ public static void main(String[] args) {
    @ for (int i =0; i < 3; i++)
    @ try{
    @ conn = getJNDIConnection();
    @ printSessionDetials();
    @ insertValuesToTempTable();
    @ QueryRecordsFromTempTable();
    @ }finally
    @ conn.close();
    @ Test Results:
    @ JNDI connection found: jdbc/xdo120DBDS
    @ V$Session Details....
    @ SessionId:299:serial#:909:Seq#:31:dbmsSessionId:012B038D0001
    @ Number of Records:1
    @ connection is closed.....
    @ =====================================
    @ JNDI connection found: jdbc/xdo120DBDS
    @ V$Session Details....
    @ SessionId:299:serial#:909:Seq#:38:dbmsSessionId:012B038D0001
    @ Number of Records:2
    @ connection is closed.....
    @ =====================================
    @ JNDI connection found: jdbc/xdo120DBDS
    @ V$Session Details....
    @ SessionId:299:serial#:909:Seq#:45:dbmsSessionId:012B038D0001
    @ Number of Records:3
    @ connection is closed.....
    @ Process exited with exit code 0.

  • JDBC(JNDI):Connection dinamically managed

    Hi all,
    I'm using
    1) Crystal Reports 2008 for the reports' design,
    2) Java Reporting Component (version 18.8.4.1094) for the integration in java environment,
    3) JBoss (version 4.2.3) as Application Server
    4) Oracle 11 as DBMS
    in a web application.
    When I create a report using JDBC (JNDI) and specify as the "Connection Name (optional)" the following string "java:jdbc/name_data_source",
    How is managed the connection of the report and any sottoreports? In other words are the connections dynamically managed by the container web or ejb?
    Thank you very much.

    Hi, Andrea,
    I'm gonna' make a few guesses here:
    2) Java Reporting Component (version 18.8.4.1094)
    I think you mean Crystal Reports for Java (CRJ) 2.8 version 12.2.209.1094. Neither the JRC (the name for the 1.x series) nor the CRJ (the 2.x series) has any version number in the 18.x range.
    sottoreports
    I think that means "subreports."
    are the connections dynamically managed by the container web or ejb?
    There are two ways the connections can be managed. If you've created a JNDI connection (a named connection), then you can base a report off of it, then at a later date change where the JNDI connection itself points to and the report should still work correctly, as long as the new target database shares the same schema as the original.
    The other way you can manage the connection is to use code to change the database connection information inside the report itself. In this way, you could change it from one JNDI connection to another or even to another type of connection altogether. Again, however, the schemas between the old and the new connections must match.
    Regards,
    Bryan

  • Cannot connect MS SQL Server2005 by using JDBC(JNDI) connection

    Hi all,
    I met a problem when I was trying to create a JDBC(JNDI) connection in crystal report 2008, the following error dialog shows up, it said:
    Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
    here is the steps how to reproduce this problem:
    1) create a DSN(Data source name) in ODBC Data Source Administrator dialog, suppose the DSN is test
        (and the DSN test show it works well)
    2) start up Crystal Report 2008, click New to create a new report, the Standard Report Creation Wizard show up
    3) expand Create New Connection node, then double click JDBC(JNDI) note
    4) the JDBC (JNDI) dialog shows up, chooose JDBC Connection in the dialog, and fill the empty fields with:
       Connection URL: jdbc:odbc:test
       Database Classname:sun.jdbc.odbc.JdbcOdbcDriver
    5) click next, it comes to the next pannel, and fill the empty fields with:
        Database: MyTestDB
        UserID: sa
        Password: sa
    6) then click Finish buttion.
    7) a new connection is created, but when I expand the new created connection, an error dialog shows up
      Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
    does anyone knows what's wrong with my setting? any help would be appreciated.
    Best Regards
    Tian-liang

    Hi Tian-liang,
    Try using Microsofts JDBC driver rather than Suns. Also search these forums, other have run into the same issue.
    Thank you
    Don

  • Sun JSAS P.E 9.0 and JNDI connection

    Hi all I am guessing this is probably in the wrong spot, so please correct me if there is a better place to put it. I am trying to setup a JNDI connection to a database, but am confused by the parameters that are required.
    I am expected to fill in the following:
    Resource Type:
    JNDI Lookup:
    Factory Class:
    But I haven't the faintest idea what these are supposed to represent. Could anyone point me to either a site with an example configuration or give me an idea of what this means ?
    thanks in advance.
    Ps. I have tried to search the web with no real results, but if they are out there let me know and I will go back to searching.

    The JDBC forum is a more appropriate place than the
    new to java. However, you have not given much
    information for anyone to work with.
    How are you setting up the connection? parameters for
    what? etc.I want to use JNDI and I am setting up it under external resources in the Server.
    It gives this: "Create an external JNDI resource so that applications can gain access to resources stored in an external respository."
    And the items I listed are those things that are required for the server.
    I am listing as much as I am aware of at this time. (Sorry if it is insufficient to help)
    PS. (Is there a method to move this post to the JDBC forum ? )
    Message was edited by:
    Aknibbs

  • Jndi connection parameters for deplyoing ejb

    Hi All,
    I am new to ejbs.I am trying to deploy session bean to jboss3.2.7 app server.Can anyone please let me know how should i pass jndi connection parameters in the client side code.In some tutorials i have seen that jndi.properties file has to be in the classpath but they didn't provide contents of it .Can anyone please let me know the solution.

    Hello SoumyaSoma,
    Please find some code cnippet I use to connect to JBoss Server. you do not need jndi.properties file.
    String url = "jnp://localhost:1099";
    Properties h = new Properties();
    h.put (Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    h.put ("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
    h.put (Context.PROVIDER_URL, url);
    Context ctx = new InitialContext(h);
    See the weblink for more information also.
    http://www.huihoo.com/jboss/online_manual/3.0/ch01s15.html
    Thanks and regards,
    Pazhanikanthan. P

Maybe you are looking for