Finding intial context factory for java naming connect to DS5

I'm a newbie to LDAP programming using the JNDI interfaces to connect to my
DS 5 implementation. I can't seem to find any reference as to where the
correct factory for the initialDirContext is! I need the factory classname
for this call:
env.put(Context.INITIAL_CONTEXT_FACTORY,"factory classname goes here");
which is neccesary to set the initialDirContext.
As far as I can tell there is no default context for an LDAP connection that
would make this easier and I don't know where or if I can find one remotely
located on my DS5 box.
Any help would be appreciated,
-Jake

I'm a newbie to LDAP programming using the JNDI interfaces to connect to my
DS 5 implementation. I can't seem to find any reference as to where the
correct factory for the initialDirContext is! I need the factory classname
for this call:
env.put(Context.INITIAL_CONTEXT_FACTORY,"factory classname goes here");
which is neccesary to set the initialDirContext.
As far as I can tell there is no default context for an LDAP connection that
would make this easier and I don't know where or if I can find one remotely
located on my DS5 box.
Any help would be appreciated,
-Jake

Similar Messages

  • Finding a Gif Encoder for Java Advanced Imaging (JAI)

    I'm trying to find the GIF encoder for Java Advanced Imaging. I keep reading all over the place that there is one, but for the life of me I can't figure out where it is supposed to be. Could anyone please enlighten me?
    Thanks

    After I installed this, it still doesn't report gif as a possible encoding type:
    String[] codecs = ImageCodec.getEncoderNames(img, null);
                for (int j = 0; j < codecs.length; j++) {
                    String codec = codecs[j];
                    System.out.println (codec);
                }only reports the following types available:
    pnm
    jpeg
    tiff
    png
    bmp

  • Problem in using context param for storing database connection information

    Hello Friends,
    I am new to struts & jsp.I am developing a project in struts.I have 1 jsp page called editProfile.jsp.On submitting this page it will call 1 action class.The action class in turn will call the Plain old java class where I have written the logic for updating User Profile.
    I have created context-param in web.xml for database connection information like dbURL , dbUserName , dbPassword , jdbcDriver.Now I want to use these connection information in my Business logic(Plain Old Java Class).As we can use context parameter only in jsp & servlets , I am setting the variables of my business logic class with these context param in jsp itself.
    now when I am calling the updateProfile method of Business logic class from Action class it is giving error as all the connection variables which I set in jsp for my business logic class has become null again.
    I am not getting.If once I have set those variables how come they are becoming null again???Please help me.Any Help will be highly appreciated.Thanx in advance.

    This is the code I have written
    web.xml file
    <context-param>
    <param-name>jdbcDriver</param-name>
    <param-value>oracle.jdbc.driver.OracleDriver</param-value>
    </context-param>
    <context-param>
    <param-name>dbUrl</param-name>
    <param-value>jdbc:oracle:thin:@localhost:1521:gd</param-value>
    </context-param>
    <context-param>
    <param-name>dbUserName</param-name>
    <param-value>system</param-value>
    </context-param>
    <context-param>
    <param-name>dbPassword</param-name>
    <param-value>password</param-value>
    </context-param>
    EditProfile.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <jsp:useBean id="EditProfile" scope="application"
    class="com.myapp.struts.EditProfile"/>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Edit My Profile</title>
    </head>
    <body>
    <form action="submitEditProfileForm.do" focus="txt_FirstName" method="post">
    <%
    EditProfile.setjdbcDriver(application.getInitParameter("jdbcDriver"));
    EditProfile.setdbURL(application.getInitParameter("dbURL"));
    EditProfile.setdbUserName(application.getInitParameter("dbUserName"));
    EditProfile.setdbPassword(application.getInitParameter("dbPassword"));
    -----------more code goes here------------
    EditActionProfile.java
    package com.myapp.struts;
    import javax.servlet.jsp.jstl.core.Config;
    import org.apache.struts.action.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class EditProfileAction extends Action {
    public EditProfileAction()
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    try
    if (isCancelled(request))
    return mapping.findForward("mainpage");
    EditProfileForm epf = (EditProfileForm)form;
    EditProfile ep = new EditProfile();
    String temp = ep.updateProfile(epf.getTxt_FirstName(),epf.getTxt_MiddleName() , epf.getTxt_LastName() , epf.getTxt_Address() , epf.getTxt_Email() );
    if(temp.equals("SUCCESS"))
    return mapping.findForward("success");
    else
    return mapping.findForward("failure");
    catch(SQLException e)
    System.out.println("error" + e.getMessage());
    return mapping.findForward("failure");
    EditProfile.java class (My Business Logic Class)
    package com.myapp.struts;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.*;
    public class EditProfile {
    private String dbURL;
    private String dbUserName , jdbcDriver;
    private String dbPassword;
    private Connection con;
    private Statement stmt;
    public EditProfile()
    public void setdbURL(String s )
    this.dbURL = s;
    public void setdbUserName(String s )
    this.dbUserName = s;
    public void setdbPassword(String s )
    this.dbPassword = s;
    public void setjdbcDriver(String s )
    this.jdbcDriver = s;
    public String updateProfile(String firstname , String middlename , String lastname , String address , String email)
    throws SQLException, ClassNotFoundException , java.lang.InstantiationException , IllegalAccessException
    try
    String s1 = new String("update usr set first_name='" + firstname + "' , middle_name='" + middlename + "' , last_name='" + lastname +"' , address='" + address + "' , email_id='" + email + "' where usr_key=1" );
    con = this.init();
    System.out.println("after init");
    stmt = con.createStatement();
    int rslt = stmt.executeUpdate(s1);
    System.out.println("after excute update");
    stmt.close();
    if(rslt>=1)
    return "SUCCESS";
    else
    return "Failure";
    finally
    if (null != con)
    con.close();
    public Connection init() throws SQLException, ClassNotFoundException
    Class.forName(jdbcDriver);
    con = DriverManager.getConnection(dbURL, dbUserName, dbPassword);
    return con;
    public void close(Connection connection) throws SQLException
    if (!connection.isClosed())
    connection.close();
    }

  • Best practice for Web Dynpro for Java to connect to SAP HR

    What is best way to connect Web Dynpro for Java application deployed in SAP portal to connect to SAP HR ?
    Is it good practice to connect to underlying SAP database ( eg oracle) directly to get the data or is there a better way ?
    This below article describes to connect to external DB, however Is there any other way for  SAP HR ?
    http://wiki.sdn.sap.com/wiki/display/WDJava/WebDynproApplciationwithDatabaseMS+Access

    Hi,
    There are 2 supported ways :
    First is  to use JCO connections to call abap RFC enabled function modules. (BAPIs for example)
    Second is to call SOAP web services (HR enterprise services for example)
    You should never access directly database tables...
    Regards,
    Olivier

  • High thread context switching for java web application

    We have been load testing our java web application and observe high cpu usage with 50 users (which doesn't seem practical). The CPU shoots up above 80%. While profiling it with java flight recording (JFR) we see that the context switch rate is 8400 per second (as seen in the Hot threads tab on java mission control). Analyzing the hot threads in jfr, it seems the cpu usage is distributed across the application threads with each thread using less than 3% cpu.
    Increasing the user load to 100, 150 or 200 users we see the cpu shooting up above 90%, the throughput (transactions per second) remaining constant (as seen for 50 users load) while the response time crosses the acceptable threshold values (3 sec). Decreasing the user load to 20 users shows the cpu usage averages out to be above 55%. It certainly isn't true that the application threads are using up the cpu since our application is not a CPU bound application. The Hot Packages tab under Code tab group confirms this by showing that most of the time the application spends in is executing database queries.
    We use glassfish 3.1.2.2 as our application server where the max thread pool is configured to be of 100. Oracle Linux Server release 6.4 is our operating system with linux kernel version as 2.6.39-400.214.4.el6uek.x86_64. I tried executing linux commands namely "watch -n0.5 pidstat -w -I -p " and "watch -n.5 grep ctxt /proc//status" to see the voluntary and involuntary thread context switching at OS level but they don't give any results.
    Suspecting that high context switching could be causing the cpu to shoot up, do you have guidelines on what could be done to confirm that thread context switching is the cause of high cpu and what are there ways to tune the jvm or the application if that's the cause?
    Thanks!

    Kelum -
    We just saw this issue today for the first time. Have you been able to find a cause?
    We upgraded our 32bit Windows operating systems this weekend to use the /3GB flag. Since then, we have seen that our servers have ample heap space, but are dangerously low in PTE memory.
    But when we've been diagnosing the state of the server that produced this error (we run 2 nodes on 3 different computers; only 1 produced this error; the other 5 are working normally), everything looked fine. The server was reporting sufficient PTE availablility, plenty of heap space, and around 172 threads (we expect to be able to run many more than that).
    When we restarted the node, it came up fine and everything appeared to be working normally.
    So I'm looking for any clue as to the root cause, and what kind of resolution to explore. Any clues or pointers would be greatly appreciated.
    Paul Christmann

  • Problem in SQL Server 2000 Driver for Java Database Connectivity

    Hi,
    I have problem with MS SQL 2000 JDBC driver. I am using Type-4 driver for my application. I can able to connect through DSN. If I use Type-4 Driver to connect database means it gives the following exception.
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
         at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
         at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
         at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
         at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at test.TestDB.main(TestDB.java:17)
    My Java Code :
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    Class.forName(driver);
    Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.48.90:1433;User=sa;Password=sa;DatabaseName=GWCANADA");
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("select * from emp");Do we have any other jdbc driver to connect MS SQL 2000 aprt from the Microsoft JDBC driver.
    Plese help me to resolve this problem
    Thanks
    ---Suresh

    Same problem is here: http://forum.java.sun.com/thread.jspa?threadID=419214&tstart=135
    Check that your server is running (telnet <hostname> 1433)
    --Xapp                                                                                                                                                                                                                                                                                                                   

  • Where can I find a portal server for JAVA development?

    Hi, everyone:
    I am looking a portal server which can be used under Windows envorinment and related development environment (toolkit or SDK).
    I have done some search through IBM and SUN's web site and I can not find any portal servers that running on Windows plarform for download and related Windows development (toolkit or SDK).
    Where can I find some trial versions of portal servers running under Windows and related Windows development (toolkit or SDK)? I want to use JAVA to development portal, so Microsoft does not provide any useful information.
    I just want to use basic functions of portal servers so I think other portal servers other than IBM and SUN's can also be used, maybe an open source one can be used. But I do not know what are they and where can I get them. :-)
    So, anyone can help me to introduce a portal server that can meet my needs. Or provide me information where to download IBM or SUN's portal server running under Windows and related Windows development (toolkit or SDK).
    Best regards,
    George

    I just want to use portal server and deploy some
    applications written in JAVA. Have I made myself
    understood?
    Still not clear.
    Do you want a server application that deploys software. For example you create a game. Someone logs into your "portal server" and downloads the game from that?
    Or do you just want to know how to package a java app that you have already written, and then put it on a CD so someone can install that on their computer?

  • Initial Context Factory for same OC4J EJB access in 10.1.3.1

    What should the INITIAL_CONTEXT_FACTORY be set to when you try to access an EJB from within the same OC4J instance? Should it be:
    a) ApplicationClientInitialContextFactory
    b) RMIInitialContextFactory
    c) Nothing at all
    d) Something else completely
    I ask because I am try to move from 10.1.3.0 to 10.1.3.1 and I have a thread spawned during startup that is unable to access the EJB
    2007-05-25 07:22:50.862 WARNING J2EE RMI-00009 Exception returned by remote server: {0}
    07/05/25 07:22:50 Unknown service: MySessionHome
    javax.naming.NameNotFoundException: MySessionHome not found
    It does not set the INITIAL_CONTEXT_FACTORY because it has been my understanding that this is not necessary. Did something change in 10.1.3.1?

    Has anyone found a solution for this problem? I tried adding the following entry to my orion-application.xml file with no luck. I was able to fix the problem by adding commons-digester.jar,commons-logging.jar, and log4j-1.2.15.jar to the /BC4J/lib folder on the server. Unfortunately this fix caused errors when trying to launch the BPEL console. Any help would be greatly appreciated.
    <imported-shared-libraries>
    <remove-inherited name="apache.commons.logging"></remove-inherited>
    </imported-shared-libraries>
    I am unable to deploy my application due to the error below.
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
            at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
            at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
            at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
            at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
            at com.sun.faces.config.ConfigureListener.<clinit>(ConfigureListener.java:212)
            ... 19 more
    Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
            at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
            at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
            ... 23 more
    Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
            at java.lang.Class.getConstructor0(Class.java:2671)
            at java.lang.Class.getConstructor(Class.java:1629)
            at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
            ... 24 more                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need to find the source code for java.util.LinkedList

    Hello all,
    I'm new to the forums and I actually need the LinkedList source file as well as all the source files for all Java packages and libraries. Please post a link here if you can, or email me at [email protected]
    Thanks again!
    copter_man

    But those must be platform dependant, not really that
    interesting to look at. I have never felt any need to
    look at those at least.Wake up and smell the coffee, abbie! I read the source code all the time and constantly tell my students to do that, too.
    1. Java source code is not platform dependent. The original poster wanted to look at linked list code, how could that be platform dependent?
    2. It is the implementation of the SDK APIs, so by definition it is implementation dependent code, liable to change in a later version. So don't assume anything beyond what is claimed in the API documentation. However, sometimes the documentation is incomplete or ambiguous to you, and reading the source can provide some insight, however implementation dependent. (Light a candle or curse the darkness.)
    3. Why read source code? It's a good way to learn how to program. You see something in the API and ask: how'd they do that? Or you realize you want to do something broadly similar, but you can't reuse the source code.
    For example, Images are not Serializable, but suppose you want a small image that is part of an object to be serialized with the rest of the object without too much fuss (ie, without using javax.imageio). You notice ImageIcon is serializable, so you use it. (An ImageIcon has-an Image.) Then you wonder: how'd they do that? You read the source and then you know.
    You live, you learn,
    Nax

  • How to find the Execution Time for Java Code?

    * Hi everyone , i want to calculate the execution time for my process in java
    * The following was the ouput for my coding,
    O/P:-
    This run took 0 Hours ;1.31 Minutes ;78.36 Seconds
    *** In the above output , the output should come exactly what hours , minutes and seconds for my process,
    but in my code the minutes are converted into seconds(It should not)...
    * Here is my coding,
        static long start_time;
        public static void startTime()
            start_time = System.currentTimeMillis();
        public static void endTime()
            DecimalFormat df = new DecimalFormat("##.##");
            long end_time = System.currentTimeMillis();
            float t = end_time - start_time;
            float sec = t / 1000;
            float min = 0, hr = 0;
            if (sec > 60) {
                min = sec / 60;
            if (min > 60) {
                hr = min / 60;
            System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
        }* How to Calcualte exact timing for my process....
    * Thanks

    * Hi flounder, Is following code will wotk perfectly?
         public static void endTime()
              DecimalFormat df = new DecimalFormat("##.##");
              long end_time = System.currentTimeMillis();
              float t = end_time - start_time;
              float sec = t / 1000;
              float min = 0, hr = 0;
              while(sec >= 60){
         min++;
         sec = sec -60;
         if (min >= 60){
         min = 0; //or min = min -60;
         hr++;
              System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
         }

  • How 2 connect webdynpro for java to R/3 system

    could any one tell me . how 2 connect web Dyn pro for java to connect to R/3 system????

    Hi,
    Pls check threads like
    Read R/3 table in Webdynpro
    Changing R/3 data in webdynpro
    or go via Jco
    http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/frameset.htm
    JCO
    Eddy
    PS. Reward useful answers and earn points yourself

  • How we build Java Database Connectivity for Oracle 8i Database

    Can any one send me a sample code for Java Database Connectivity for Oracle 8i Database
    it will be a grat help
    Thanks & Regards
    Rasika

    You don't need a DSN if you use Oracle's JDBC driver.
    You didn't read ANY of the previous replies. What makes you think this one willk help? Or any instruction, for that matter?
    Sounds like you just want someone to give it to you. OK, I'll bite, but you have to figure out the rest:
    import java.sql.*;
    import java.util.*;
    * Command line app that allows a user to connect with a database and
    * execute any valid SQL against it
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        public static final String DEFAULT_DRIVER   = "com.mysql.jdbc.Driver";
        public static final String DEFAULT_URL      = "jdbc:mysql://localhost:3306/hibernate";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    System.out.println("sql     : " + sql);
                    System.out.println("driver  : " + driver);
                    System.out.println("url     : " + url);
                    System.out.println("username: " + username);
                    System.out.println("password: " + password);
                    db = new DataConnection(driver, url, username, password);
                    System.out.println("Connection established");
                    Object result = db.executeSQL(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Get Driver properties
         * @param database URL
         * @return list of driver properties
         * @throws SQLException if the query fails
        public List getDriverProperties(final String url)
            throws SQLException
            List driverProperties   = new ArrayList();
            Driver driver           = DriverManager.getDriver(url);
            if (driver != null)
                DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
                if (info != null)
                    driverProperties    = Arrays.asList(info);
            return driverProperties;
         * Clean up the connection
        public void close()
            close(this.connection);
         * Execute ANY SQL statement
         * @param SQL statement to execute
         * @returns list of row values if a ResultSet is returned,
         * OR an altered row count object if not
         * @throws SQLException if the query fails
        public Object executeSQL(final String sql) throws SQLException
            Object returnValue;
            Statement statement = null;
            ResultSet rs = null;
            try
                statement = this.connection.createStatement();
                boolean hasResultSet    = statement.execute(sql);
                if (hasResultSet)
                    rs                      = statement.getResultSet();
                    ResultSetMetaData meta  = rs.getMetaData();
                    int numColumns          = meta.getColumnCount();
                    List rows               = new ArrayList();
                    while (rs.next())
                        Map thisRow = new LinkedHashMap();
                        for (int i = 1; i <= numColumns; ++i)
                            String columnName   = meta.getColumnName(i);
                            Object value        = rs.getObject(columnName);
                            thisRow.put(columnName, value);
                        rows.add(thisRow);
                    returnValue = rows;
            else
                int updateCount = statement.getUpdateCount();
                returnValue     = new Integer(updateCount);
            finally
                close(rs);
                close(statement);
            return returnValue;
         * Close a database connection
         * @param connection to close
        public static final void close(Connection connection)
            try
                if (connection != null)
                    connection.close();
                    connection = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a statement
         * @param statement to close
        public static final void close(Statement statement)
            try
                if (statement != null)
                    statement.close();
                    statement = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a result set
         * @param rs to close
        public static final void close(ResultSet rs)
            try
                if (rs != null)
                    rs.close();
                    rs = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a database connection and statement
         * @param connection to close
         * @param statement to close
        public static final void close(Connection connection, Statement statement)
            close(statement);
            close(connection);
         * Close a database connection, statement, and result set
         * @param connection to close
         * @param statement to close
         * @param rs to close
        public static final void close(Connection connection,
                                       Statement statement,
                                       ResultSet rs)
            close(rs);
            close(statement);
            close(connection);
    }%

  • Creating initial context from a java client

    I have tried to create intial context from a java client.....
    but that gives me the following exception:
    My code:TestClient.java
    import java.util.*;
    import javax.naming.*;
    public class TestClient
    public static void main(String nilesh[]) throws NamingException
    Hashtable hash = new Hashtable();
    hash.put("Context.INITIAL_CONEXT_FACTORY","com.evermind.server.rmi.RMIInitialContextFactory");
    hash.put("Context.PROVIDER_URL","ormi://localhost:23791/symularity");
    hash.put("Context.SECURITY_PRINCIPAL","admin");
    hash.put("Context.SECURITY_CREDENTIALS","admin");
    Context ctx = new InitialContext(hash);
    System.out.println("Context: "+ctx);
    The output is:
    ERROR! Shared library ioser12 could not be found.
    Exception in thread "main" javax.naming.NamingException: Error accessing repository: Cannot con
    nect to ORB
    at com.sun.enterprise.naming.EJBCtx.<init>(EJBCtx.java:51)
    at com.sun.enterprise.naming.EJBInitialContextFactory.getInitialContext(EJBInitialConte
    xtFactory.java:62)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at TestClient.main(TestClient.java:14)
    is anybody able to solve my problem....
    Thanks in advance..
    NileshG

    Nilesh,
    First of all make sure that the shared library error you are getting is fixed by including the library in your classpath. Secondly, where are you running the client from? The connection factory that you use varies depending on where you are connecting from:
    1. ApplicationClientContextFactory is used when looking up remote objects from standalone application clients. This uses refs and mappings in application-client.xml.
    2. RMInitialContextFactory is used when looking up remote objects between different containers.
    3. ApplicationInitalContextFactory is used when looking up remote objects in same application. This is the default initial context factory and this uses refs/mappings in web.xml and ejb-jar.xml.
    Rob Cole
    Oracle Hello Rob cole..
    thank u for ur reply...but actualy i dont know what is application-client.xml and where i can find that file in my j2ee folder...can u give me detail explanation about that...actually i have not created any application or not deployed also without deploying any application i have created that TestClient.java class so how it will relate with application-client.xml....so i have changed the lookup code with ApplicaitonClientContextFactory...but still the same error is coming......can u give me the full explanation or solution of my problem...
    Thanks & Regards
    NileshG...

  • NSService for Java App

    Hello,
    I have one Java app name "hill-resort", which registers for a service(NSService) on start. I have written JNI code to receive service request in my running java app. and in my app Info.plist, I have created Service entries. I am passing the file/folder name from mac context menu to my java app using JNI, till now it was working fine, but suddenly it has started giving error like:
    2014-07-19 18:52:56.807 hill-resort[2050:507] Failed to obtain a valid sandbox extension for item: [789514] of flavor: [public.file-url] from the pasteboard.
    2014-07-19 18:52:56.808 hill-resort[2050:507] Failed to get a sandbox extensions for itemIdentifier (789514).  The data for the sandbox extension was NULL
    And it is taking 3 to 10 seconds to get a call in java from the service, earlier it was instantaneous.
    I have google around to find out how to fix it, but haven't find a workable solution for Java app.
    Please help, how to fix it!

    > This is a continuation of a previous issue I've been working on. This
    > falls into the realm of filters, so I thought I'd move it here.
    The same sysops cover all the BM forums, therefore it doesn't matter.
    > I have a
    > java app that needs to connect to the internet. It works fine when I
    > unload ipflt. Using filter debug, it seems as if packets are going out
    > correctly, but are being dropped coming back. I thought, that with dynamic
    > NAT, I wouldn't have to create an inbound exception. Am I off base with that?
    Is the exception you made STATEFUL? If it's not stateful the return
    packets will be dropped.
    Cat
    NSC Volunteer Sysop

  • JDBC is the Acronym of Java Database Connectivity - Yes / No?

    Hi,
    JDBC is the Acronym of Java Database Connectivity - Yes / No?
    I am little bit confused. I got this question in an Inteview.
    I support yes. But some of the compitiors say no.
    What will the real answer?

    Really? Even Sun contradicts themselves here:
    (2002) http://java.sun.com/javase/6/docs/technotes/guides/jdbc/
    and (more importantly) here:
    http://java.sun.com/docs/glossary.html#JDBC
    although here:
    (2001) http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/intro.html
    I think it is simply silly for the latter to state that "JDBC is the trademarked name and is not an acronym" -- Oh really? JDBC doesn't stand for anything? It is all caps just because it is a trademark then? hmmm.
    I'm certain the real answer of what it stands for may have been lost long ago. However, I doubt that the interviewer meant the question to be a trick and was looking for "Java DataBase Connectivity"
    For every instance that you find that it doesn't stand for anything, I can show you 2 instances (from Sun or an employee) where they use "Java Database Connectivity (JDBC)".
    P.S. Ryan Craig may be the final authority on this...

Maybe you are looking for

  • Image processing with applets

    Hi I need to create a website with several image processing applets on it. however although the applets work locally they will not load at all through a server (i'm a student) my supervisor tells me i cant use an applet to display an image stored on

  • Unable to send mail with different fonts and colors

    Hi All, here is the explanation for my problem: I am sending mail using javamail. when i send the text with different font and color its not received in the same way. it is simply sending as plain text. Please help me on this issue. Thanks NG

  • OIM 11g R1 - change xelsysadm passwords

    Hello, i need to change the passwords for xelsysadm. Where do i have to change all the passwords for xelsysadm? - OIM - OID (LDAP) - Credential Store Provider in EM (sysadmin = xelsysadm) - ???

  • Changing router to 3rd party router

    I've been thinking about upgrading my router to a 3rd party AC wireless router so I can use more of my bandwith on my laptop and other wireless gadgets.  My question is can I change it and keep all my tv services. I was told I have to use verizon's a

  • OBJECT_ID for a PK or Index

    Hi friends, With a need for the first time to check if a PK and an Index exists before dropping and re-creating the same need your help. IF OBJECT_ID(N'PK_LMT', N'PK') IS NOT NULL SELECT 1 (does not work and reflects Command(s) completed successfully