How to Commit table by writting Java code in Managed Bean?

Hi,
Can anyone suggest me how to Commit table by writing Java code in Managed Bean?.
I want to commit table manually after modifying in UI.
Please suggest me guys.
Thanks,
Ramit Mathur

Hi Friend Copy this two java files with same package of your bean package.
1,*ADFUtils.java*
package org.calwin.common.view.utils;(Your package name)
import java.util.ArrayList;
import java.util.List;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.model.binding.DCParameter;
import oracle.adf.share.logging.ADFLogger;
import oracle.binding.AttributeBinding;
import oracle.binding.BindingContainer;
import oracle.binding.ControlBinding;
import oracle.binding.OperationBinding;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.uicli.binding.JUCtrlValueBinding;
* A series of convenience functions for dealing with ADF Bindings.
* Note: Updated for JDeveloper 11
* @author Duncan Mills
* @author Steve Muench
* $Id: ADFUtils.java 2513 2007-09-20 20:39:13Z ralsmith $.
public class ADFUtils
public static final ADFLogger _LOGGER = ADFLogger.createADFLogger(ADFUtils.class);
* Get application module for an application module data control by name.
* @param pName application module data control name
* @return ApplicationModule
public static ApplicationModule getApplicationModuleForDataControl(String pName)
return (ApplicationModule) JSFUtils.resolveExpression("#{data." + pName + ".dataProvider}");
* A convenience method for getting the value of a bound attribute in the
* current page context programatically.
* @param pAttributeName of the bound value in the pageDef
* @return value of the attribute
public static Object getBoundAttributeValue(String pAttributeName)
return findControlBinding(pAttributeName).getInputValue();
* A convenience method for setting the value of a bound attribute in the
* context of the current page.
* @param pAttributeName of the bound value in the pageDef
* @param pValue to set
public static void setBoundAttributeValue(String pAttributeName, Object pValue)
findControlBinding(pAttributeName).setInputValue(pValue);
* Returns the evaluated value of a pageDef parameter.
* @param pPageDefName reference to the page definition file of the page with the parameter
* @param pParameterName name of the pagedef parameter
* @return evaluated value of the parameter as a String
public static Object getPageDefParameterValue(String pPageDefName, String pParameterName)
BindingContainer bindings = findBindingContainer(pPageDefName);
DCParameter param = ((DCBindingContainer) bindings).findParameter(pParameterName);
return param.getValue();
* Convenience method to find a DCControlBinding as an AttributeBinding
* to get able to then call getInputValue() or setInputValue() on it.
* @param pBindingContainer binding container
* @param pAttributeName name of the attribute binding.
* @return the control value binding with the name passed in.
public static AttributeBinding findControlBinding(BindingContainer pBindingContainer, String pAttributeName)
if (pAttributeName != null)
if (pBindingContainer != null)
ControlBinding ctrlBinding = pBindingContainer.getControlBinding(pAttributeName);
if (ctrlBinding instanceof AttributeBinding)
return (AttributeBinding) ctrlBinding;
return null;
* Convenience method to find a DCControlBinding as a JUCtrlValueBinding
* to get able to then call getInputValue() or setInputValue() on it.
* @param pAttributeName name of the attribute binding.
* @return the control value binding with the name passed in.
public static AttributeBinding findControlBinding(String pAttributeName)
return findControlBinding(getBindingContainer(), pAttributeName);
* Return the current page's binding container.
* @return the current page's binding container
public static BindingContainer getBindingContainer()
return (BindingContainer) JSFUtils.resolveExpression("#{bindings}");
* Return the Binding Container as a DCBindingContainer.
* @return current binding container as a DCBindingContainer
public static DCBindingContainer getDCBindingContainer()
return (DCBindingContainer) getBindingContainer();
* Get List of ADF Faces SelectItem for an iterator binding.
* Uses the value of the 'valueAttrName' attribute as the key for
* the SelectItem key.
* @param pIteratorName ADF iterator binding name
* @param pValueAttrName name of the value attribute to use
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @return ADF Faces SelectItem for an iterator binding
public static List<SelectItem> selectItemsForIterator(String pIteratorName, String pValueAttrName, String pDisplayAttrName)
return selectItemsForIterator(findIterator(pIteratorName), pValueAttrName, pDisplayAttrName);
* Get List of ADF Faces SelectItem for an iterator binding with description.
* Uses the value of the 'valueAttrName' attribute as the key for
* the SelectItem key.
* @param pIteratorName ADF iterator binding name
* @param pValueAttrName name of the value attribute to use
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @param pDescriptionAttrName name of the attribute to use for description
* @return ADF Faces SelectItem for an iterator binding with description
public static List<SelectItem> selectItemsForIterator(String pIteratorName, String pValueAttrName, String pDisplayAttrName, String pDescriptionAttrName)
return selectItemsForIterator(findIterator(pIteratorName), pValueAttrName, pDisplayAttrName, pDescriptionAttrName);
* Get List of attribute values for an iterator.
* @param pIteratorName ADF iterator binding name
* @param pValueAttrName value attribute to use
* @return List of attribute values for an iterator
public static List attributeListForIterator(String pIteratorName, String pValueAttrName)
return attributeListForIterator(findIterator(pIteratorName), pValueAttrName);
* Get List of Key objects for rows in an iterator.
* @param pIteratorName iterabot binding name
* @return List of Key objects for rows
public static List<Key> keyListForIterator(String pIteratorName)
return keyListForIterator(findIterator(pIteratorName));
* Get List of Key objects for rows in an iterator.
* @param pIterator iterator binding
* @return List of Key objects for rows
public static List<Key> keyListForIterator(DCIteratorBinding pIterator)
List<Key> attributeList = new ArrayList<Key>();
for (Row r: pIterator.getAllRowsInRange())
attributeList.add(r.getKey());
return attributeList;
* Get List of Key objects for rows in an iterator using key attribute.
* @param pIteratorName iterator binding name
* @param pKeyAttrName name of key attribute to use
* @return List of Key objects for rows
public static List<Key> keyAttrListForIterator(String pIteratorName, String pKeyAttrName)
return keyAttrListForIterator(findIterator(pIteratorName), pKeyAttrName);
* Get List of Key objects for rows in an iterator using key attribute.
* @param pIterator iterator binding
* @param pKeyAttrName name of key attribute to use
* @return List of Key objects for rows
public static List<Key> keyAttrListForIterator(DCIteratorBinding pIterator, String pKeyAttrName)
List<Key> attributeList = new ArrayList<Key>();
for (Row r: pIterator.getAllRowsInRange())
attributeList.add(new Key(new Object[]
{ r.getAttribute(pKeyAttrName) }));
return attributeList;
* Get a List of attribute values for an iterator.
* @param pIterator iterator binding
* @param pValueAttrName name of value attribute to use
* @return List of attribute values
public static List attributeListForIterator(DCIteratorBinding pIterator, String pValueAttrName)
List attributeList = new ArrayList();
for (Row r: pIterator.getAllRowsInRange())
attributeList.add(r.getAttribute(pValueAttrName));
return attributeList;
* Find an iterator binding in the current binding container by name.
* @param pName iterator binding name
* @return iterator binding
public static DCIteratorBinding findIterator(String pName)
DCIteratorBinding iter = getDCBindingContainer().findIteratorBinding(pName);
if (iter == null)
throw new RuntimeException("Iterator '" + pName + "' not found");
return iter;
* @param pBindingContainer
* @param pIterator
* @return
public static DCIteratorBinding findIterator(String pBindingContainer, String pIterator)
DCBindingContainer bindings = (DCBindingContainer) JSFUtils.resolveExpression("#{" + pBindingContainer + "}");
if (bindings == null)
throw new RuntimeException("Binding container '" + pBindingContainer + "' not found");
DCIteratorBinding iter = bindings.findIteratorBinding(pIterator);
if (iter == null)
throw new RuntimeException("Iterator '" + pIterator + "' not found");
return iter;
* @param pName
* @return
public static JUCtrlValueBinding findCtrlBinding(String pName)
JUCtrlValueBinding rowBinding = (JUCtrlValueBinding) getDCBindingContainer().findCtrlBinding(pName);
if (rowBinding == null)
throw new RuntimeException("CtrlBinding " + pName + "' not found");
return rowBinding;
* Find an operation binding in the current binding container by name.
* @param pName operation binding name
* @return operation binding
public static OperationBinding findOperation(String pName)
OperationBinding op = getDCBindingContainer().getOperationBinding(pName);
if (op == null)
throw new RuntimeException("Operation '" + pName + "' not found");
return op;
* Find an operation binding in the current binding container by name.
* @param pBindingContianer binding container name
* @param pOpName operation binding name
* @return operation binding
public static OperationBinding findOperation(String pBindingContianer, String pOpName)
DCBindingContainer bindings = (DCBindingContainer) JSFUtils.resolveExpression("#{" + pBindingContianer + "}");
if (bindings == null)
throw new RuntimeException("Binding container '" + pBindingContianer + "' not found");
OperationBinding op = bindings.getOperationBinding(pOpName);
if (op == null)
throw new RuntimeException("Operation '" + pOpName + "' not found");
return op;
* Get List of ADF Faces SelectItem for an iterator binding with description.
* Uses the value of the 'valueAttrName' attribute as the key for
* the SelectItem key.
* @param pIterator ADF iterator binding
* @param pValueAttrName name of value attribute to use for key
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @param pDescriptionAttrName name of the attribute for description
* @return ADF Faces SelectItem for an iterator binding with description
public static List<SelectItem> selectItemsForIterator(DCIteratorBinding pIterator, String pValueAttrName, String pDisplayAttrName, String pDescriptionAttrName)
List<SelectItem> selectItems = new ArrayList<SelectItem>();
for (Row r: pIterator.getAllRowsInRange())
selectItems.add(new SelectItem(r.getAttribute(pValueAttrName), (String) r.getAttribute(pDisplayAttrName), (String) r.getAttribute(pDescriptionAttrName)));
return selectItems;
* Get List of ADF Faces SelectItem for an iterator binding.
* Uses the value of the 'valueAttrName' attribute as the key for
* the SelectItem key.
* @param pIterator ADF iterator binding
* @param pValueAttrName name of value attribute to use for key
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @return ADF Faces SelectItem for an iterator binding
public static List<SelectItem> selectItemsForIterator(DCIteratorBinding pIterator, String pValueAttrName, String pDisplayAttrName)
List<SelectItem> selectItems = new ArrayList<SelectItem>();
for (Row r: pIterator.getAllRowsInRange())
selectItems.add(new SelectItem(r.getAttribute(pValueAttrName), (String) r.getAttribute(pDisplayAttrName)));
return selectItems;
* Get List of ADF Faces SelectItem for an iterator binding.
* Uses the rowKey of each row as the SelectItem key.
* @param pIteratorName ADF iterator binding name
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @return ADF Faces SelectItem for an iterator binding
public static List<SelectItem> selectItemsByKeyForIterator(String pIteratorName, String pDisplayAttrName)
return selectItemsByKeyForIterator(findIterator(pIteratorName), pDisplayAttrName);
* Get List of ADF Faces SelectItem for an iterator binding with discription.
* Uses the rowKey of each row as the SelectItem key.
* @param pIteratorName ADF iterator binding name
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @param pDescriptionAttrName name of the attribute for description
* @return ADF Faces SelectItem for an iterator binding with discription
public static List<SelectItem> selectItemsByKeyForIterator(String pIteratorName, String pDisplayAttrName, String pDescriptionAttrName)
return selectItemsByKeyForIterator(findIterator(pIteratorName), pDisplayAttrName, pDescriptionAttrName);
* Get List of ADF Faces SelectItem for an iterator binding with discription.
* Uses the rowKey of each row as the SelectItem key.
* @param pIterator ADF iterator binding
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @param pDescriptionAttrName name of the attribute for description
* @return ADF Faces SelectItem for an iterator binding with discription
public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding pIterator, String pDisplayAttrName, String pDescriptionAttrName)
List<SelectItem> selectItems = new ArrayList<SelectItem>();
for (Row r: pIterator.getAllRowsInRange())
selectItems.add(new SelectItem(r.getKey(), (String) r.getAttribute(pDisplayAttrName), (String) r.getAttribute(pDescriptionAttrName)));
return selectItems;
* Get List of ADF Faces SelectItem for an iterator binding.
* Uses the rowKey of each row as the SelectItem key.
* @param pIterator ADF iterator binding
* @param pDisplayAttrName name of the attribute from iterator rows to display
* @return List of ADF Faces SelectItem for an iterator binding
public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding pIterator, String pDisplayAttrName)
List<SelectItem> selectItems = new ArrayList<SelectItem>();
for (Row r: pIterator.getAllRowsInRange())
selectItems.add(new SelectItem(r.getKey(), (String) r.getAttribute(pDisplayAttrName)));
return selectItems;
* Find the BindingContainer for a page definition by name.
* Typically used to refer eagerly to page definition parameters. It is
* not best practice to reference or set bindings in binding containers
* that are not the one for the current page.
* @param pPageDefName name of the page defintion XML file to use
* @return BindingContainer ref for the named definition
private static BindingContainer findBindingContainer(String pPageDefName)
BindingContext bctx = getDCBindingContainer().getBindingContext();
BindingContainer foundContainer = bctx.findBindingContainer(pPageDefName);
return foundContainer;
* @param pOpList
public static void printOperationBindingExceptions(List pOpList)
if (pOpList != null && !pOpList.isEmpty())
for (Object error: pOpList)
_LOGGER.severe(error.toString());
* Programmatic invocation of a method that an EL evaluates to.
* The method must not take any parameters.
* @param pEl EL of the method to invoke
* @return Object that the method returns
public static Object invokeEL(String pEl)
return invokeEL(pEl, new Class[0], new Object[0]);
* Programmatic invocation of a method that an EL evaluates to.
* @param pEl EL of the method to invoke
* @param pParamTypes Array of Class defining the types of the parameters
* @param pParams Array of Object defining the values of the parametrs
* @return Object that the method returns
public static Object invokeEL(String pEl, Class[] pParamTypes, Object[] pParams)
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
MethodExpression exp = expressionFactory.createMethodExpression(elContext, pEl, Object.class, pParamTypes);
return exp.invoke(elContext, pParams);
* Sets the EL Expression with the value.
* @param pEl EL Expression for which the value to be assigned.
* @param pVal Value to be assigned.
public static void setEL(String pEl, Object pVal)
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, pEl, Object.class);
exp.setValue(elContext, pVal);
* Evaluates the EL Expression and returns its value.
* @param pEl Expression to be evaluated.
* @return Value of the expression as Object.
public static Object evaluateEL(String pEl)
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, pEl, Object.class);
return exp.getValue(elContext);
}

Similar Messages

  • How to write java code to read the pixel color in some place of screen?

    Hello all:
    How to write java code to read the pixel color in some place of screen?
    The java application iteself doesn't have any GUI.
    thank you
    -Danel

    See java.awt.Robot

  • Access ABAP tables using NWDS Java Code

    All,
    I am planning to write a program to autmatically update is_url entries in sxmb_admin using a Java program.
    Is there a way we can access the ABAP tables using standalone Java Code? would it something like dblookup that we use in the mappings?
    Your Thoughts....
    Thanks.

    Hi Vicky - Interesting..Seems like you are trying to automate every single thing
    However you can make use of Jco to connect to ABAP tables..
    Check the below thread..
    Help on accessing tables of SAP from the Java Application
    I assume the table name is "SXMSCONFVLV" which you might have to update but not sure..

  • Where do i write java code

    I am a java beginner. i need to know which interface i can use to write java code

    Hi ,
    u can write java code in many places
      notepad,
      edit plus ,
      eclipse ,
      netbeans ,
      NWDS (in j2ee perspective thisis for sap side )
    all the thing u need to install jdk first ...
    set your class path .
    go to command promt -> type cmd
    ur command prompt opens .
    open note pad write some code
    execute in command promt  by typing javac  abc.java
    i fno errors  type  java abc
    ur code will be executed and result displayed
    regards ,
    venkat p

  • Can i write java code in JavaScript function

    I want to call JavaBeans within JavaScript function. Can I do it?
    I have a button in JSP . When the button be clicked,the data be inputted will be checked by JavaScript function. If check is ok, then call a Bean's function to write the data to database.
    Please Help!

    well indeed u can write java code in javascript functions. But probably it will not work the way u want it to.
    when u say that u click a button, it means that some client side action is performed. Now if u wud require a java bean to be called then it means that the server needs to be contacted for the same, and if that has to be done, necessarily the form needs to be submitted.
    U can populate values from a java bean and then the same can be made available to a javascript variable / function when the page is loaded rather than, when the button is clicked.
    What u can do is on click of button u can process [display / calulate..etc ] the information which has already been got by the java bean.
    Kris

  • Selected node in a tree table (via Data Controls and not managed bean)

    I am facing some problems in getting the selected row in a tree table.I have used data controls for creating the tree on the page.
    I have 3 POJO's,ex; Class AB which has a list of Class CD.And Class CD has a list of class EF. (Used for the tree table)
    Now i have a java class, called MyDelegate.java which has a list of AB.I generated data controls off this MyDelegate class and have dropped the ABlist as a tree table (also displaying CD and EF in the tree table).
    It displays fine with nodes of AB,CD (child of AB)and EF(child of CD)
    The tree table is not bound to any managed bean.
    For performing actions on the tree, i create a method - "doSomething() in the delegate class",generate data controls and drop it as a button.
    Inside doSomething(), i need acess to the selected node in the tree (it can be a node of type AB or CD or EF).
    The problem: I always get access to the node of type AB, and not the child nodes no matter what i click in the tree table.
    doSomething(){
    DCBindingContainer dcBindingContainer = (DCBindingContainer)ADFUtil.evaluateEL("#{bindings}");
    DCIteratorBinding dcTreeIteratorBinding = dcBindingContainer.findIteratorBinding("lstABIterator");
    RowSetIterator rowTreeSetIterator = dcTreeIteratorBinding.getRowSetIterator();
    DCDataRow rowTree = (DCDataRow)rowTreeSetIterator.getCurrentRow();
    if (rowTree.getDataProvider() instanceof AB) {
              //do something
              AB selectedAB = (AB)row.getDataProvider();
    } else if (rowTree.getDataProvider() instanceof CD){
              //do something
    } else if (rowTree.getDataProvider() instanceof EF) {
              // do something
    How do i access the "selected child node of the tree table" here in the delegate class method? Pls help.

    Hi Frank,
    Thanks for the response. In my case, i dont have a managed bean, so i am slightly unsure how to do it.
    There is a mention "Note that another way to access the treeTable component at runtime is to search for it in JavaServer Faces UIViewRoot. This latter option allows you to write more generic code and does not require to create a page dependency to a managed bean"
    How do i use this adf view root (without a managed bean) to get hold of the selected row in the tree table. Pls help.
    Thanks.

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • How can I write java code in web dynpro to show KM content document?

    Dear all developer
    SDN developer who have any easy example java code for get and show KM content documents(documents/com.xx.km/.). We are develop this project by Netweaver Studio 7.0 and using WEB Dynpro application.
    Thank for all comment and advice.
    Jumnong Boonma

    Hi
    i dont have the exact code but yes..i can refer to the link for Web Dynpro applications for the Portal.
    [http://help.sap.com/erp2005_ehp_03/helpdata/EN/42/fa080514793ee6e10000000a1553f7/frameset.htm]
    Here look out for Absolute Navigation.
    Hope it helps...
    Thanks..

  • How to use Oracle objects in java code

    Hi all!
    I'm reading an xls and i need to fill me oracle objects with java code:
    OBJECT_NAME OBJECT_TYPE
    LETTURA_OBJ TYPE
    LETTURA_OBJ TYPE BODY
    In the past weeks i've been using both java code into oracle and oracle objects, but new i need to write those objects with data i read with java, anybody can help me?
    I know that the easiest work around would be to put the data i read from the excel file into a table and then fill the oracle objects, but now i want to learn how to write directly those objects with a command like the following one:
    a sample of the code i'm tryng to write:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import jxl.*;
    public cass ....
    #sql{  variabili_globali.var_ER_F3.Tipo_Lettura := 5}
    thanks,
    Massimo
    Edited by: LinoPisto on 16-mag-2011 16.38

    mmmh i'm not understanding so much....
    well... as i told before i'm working in oracle database environment and i'm developing a java procedure.
    now, i have this object
    CREATE OR REPLACE
    TYPE REPORT.FATTURA_OBJ AS OBJECT (
    POD VARCHAR2(1000),
    ID_FATTURA NUMBER,
    ID_FILE NUMBER,
    COERENZA_EA_F VARCHAR2(1000),
    COERENZA_ER_F VARCHAR2(1000),
    COERENZA_EA_M VARCHAR2(1000),
    COERENZA_EF_M VARCHAR2(1000),
    ANOMALIA VARCHAR2(1000),
    MOTIVO_INVALIDAZIONE VARCHAR2(1000),
    MATRICOLA_CONTATORE VARCHAR2(1000),
    POTENZA_DISPONIBILE VARCHAR2(1000),
    MEMBER PROCEDURE pulisci
    /and i need to work with it inside this procedure:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import java.io.StringWriter;
    public class Manage_Excel_ASMBS
    public static void read_Excel(String inputFile,int var_Id_Caricamento, int var_Id_Distributore, String var_Distributore) throws SQLException, IOException
              **here i need to put what i'm reading inside the excel file into oracle objects**
    /can you please give me a sample ?
    thanks

  • How to get MAC address using java code

    hi friends
    please write me, How can I get MAC Address of local machine using java code.I don't want to use JNI.
    Please reply me. Its urgent for me
    Thanks in advance
    US

    You have several ways under *nix
    ifconfig -a | grep HWwill output something like
    eth0      Lien encap:Ethernet  HWaddr 00:11:FF:74:FF:B4combined with Runtime.getRuntime().exec("")and Process.getInputStream()you should be able to read it easilly.
    Under Windows (and Linux of course) try jpcap (http://sourceforge.net/projects/jpcap)
    You can also use jnative as a generic tool (http://sourceforge.net/projects/jnative)
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to retrive table names with Java?

    Hello!
    If I connect to my Oracle Database 10g Express Edition Instance with some Java code and I run the following code:
                   ResultSet resultSet = databaseMetaData.getTables(null, null, "%", types);
                   while( resultSet.next() )
                        String tableName = resultSet.getString(3);
                        System.out.println(tableName);
    I get loads of different names of tables beside those that belongs to my user like:
    DR$NUMBER_SEQUENCE
    DR$OBJECT_ATTRIBUTE
    DR$POLICY_TAB
    ARTICLES
    BIN$tQZXQ0iGufbgQAB/AQELFg==$0
    BIN$tQZXQ0iLufbgQAB/AQELFg==$0
    But when I log in to http://127.0.0.1:9090/apex I get a perfect list of the tables belonging to the user:
    ARTICLES
    CUSTOMERS
    DATATYPES
    ORDERROWS
    ORDERS
    REQUESTROWS
    REQUESTS
    SUPPLIERROWS
    SUPPLIERS
    Does any one understand how to access just these table names that is created with my user?
    Best regards
    Fredrik

    Hello Adrian!
    Yes you are right I now understand that this is the wrong forum.
    So I posted the "same question" at:
    How to retrive table names belonging only to a user?
    How ever I seems to have problem with the schema name parameter any way.
    Best regards
    Fredrik

  • Until how many lines can we  write java file

    in java file, how many lines can I write?
    Manybe It will depend on file system such as window, unix file system.
    but, I don't know the exact size.
    please let me know how many lines I can wirte in java file of window and unix file system.
    thank you in advance.

    A class and method implementation in source lines of code (sans comments and white space) should be as large as necessary, but no larger. Good design principals tend to drive towards smaller peices, but there is no one right size size limit.
    Personally, I suspect any method that has over 50 lines of code as being too large and probably refactorable. I also suspect any single class (or for that matter .java file) with more than 50 methods or more than 2000 lines of code as being too large and probably refactorable. But sometimes we might really need a 500 line method or an 8000 line, 200 method class. Maybe its a performance thing. Maybe it is just that complicated and too hard to break up. I doubt it occurs frequently, but I won't be shocked when I see it.
    Sometimes GUI classes (Swing and AWT) get really huge. Sometimes this is due to code generation, sometimes its just being sloppy. It pays to know the difference.
    But the Java langauge sets reasonable (if not overly generous) limits on bytecode and constant pool sizes If the Java compiler begins to complain that something you have built is is too large, face it, it probably is. It's like running into scope nesting or nested name (class in a class in a class...) size limits - usually not a good sign for the structure of your code.
    Chuck

  • How to copy a file from Java code

    I have written a file through Java code in folder, say, "A". Now, I want a copy of that file exactly the same in some other folder "B". How, it can be done?

    http://java.sun.com/docs/books/tutorial/essential/io/streams.html

  • How to display pdf file with java code?

    Hi All,
    i have a jsp pagein that page if i click one icon then my backing bean method will call and that method will create pdf document and write some the content in that file and now i want to display that generated pdf document.
    it should look like you have pressed one icon and it displayed pdf file to you to view.
    java code below:
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "filename=\"" + temppdfFile);
    resp.encodeRedirectURL(temppdfFile.getAbsolutePath());
    resp.setContentType("application/pdf");
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(temppdfFile, out);
    out.flush();
    and above temppdfFile is my generated pdf file.
    when i am executing this code, it was opening dialog box for save and cancel for the file, but the name of the file it was showing me the "jsp file name" with no file extention (in wich jsp file i am calling my backing bean method) and type is "Unknown File type" and from is "local host"
    it was not showing me open option so i am saving that file then that file saved as a pdffile with tha name of my jsp file and there is nothing in that file(i.e. empty file).
    what is the solution for this. there is any wrong in my code.
    Please suggest me.
    Thanks in advance
    Indira

    public Object buildBarCodes() throws Exception
    File bulkBarcodes = null;
    String tempPDFFile = this.makeTempDir();
    File tempDir = new File("BulkPDF_Files_Print");
    if(!tempDir.exists())
    tempDir.mkdir();
    bulkBarcodes = File.createTempFile
    (tempPDFFile, ".pdf", tempDir);
    //bulkBarcodes = new File(tempDir, tempPDFFile+"BulkBarcode"+"."+"pdf");
    if(!bulkBarcodes.exists())
    bulkBarcodes.createNewFile();
    Document document = new Document();
    FileOutputStream combinedOutput = new FileOutputStream(bulkBarcodes);
    PdfWriter.getInstance(document, combinedOutput);
    document.open();
    document.add(new Paragraph("\n"));
    document.add(new Paragraph("\n"));
    Image image = Image.getInstance(bc.generateBarcodeBytes(bc.getBarcode()));
    document.add(image);
    combinedOutput.flush();
    document.close();
    combinedOutput.close();
    FacesContext facesc = FacesContext.getCurrentInstance();
    ExternalContext ec = facesc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "inline: BulkBarcodes.pdf");
    resp.encodeRedirectURL(bulkBarcodes.getAbsolutePath());
    resp.setContentType("application/pdf");
    resp.setBufferSize(10000000);
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(bulkBarcodes, out);
    out.flush();
    return "success";
    This is my action method which will call when ever i press a button in my jsp page.
    This method will create the barcode for the given barcode number and write that barcode image in pdf file
    (i saw that pdf file which i have created through my above method, This PDF file opening when i was opening manually and the data init that is also correct means successfully it writes the mage of that barcode)
    This method taking the jsp file to open because as earlier i said it was trying to open unknown file type document and i saved that file and opended with editplus and that was the jsp file in which file i am calling my action method I mean to say it was not taking the pdf file which i have created above it was taking the jsp file

  • How to compile connection pool sample java code

    I recently bought David Knox's "Effective Oracle Database 10g Security by Design", and have been working through his examples with client identifiers and how to leverage database security with anonymous connection pools.
    The database side of things I totally understand and have set up, but I now want to compile/run the java code examples, but don't know what is required to compile this.
    I'm running Oracle 10.2.0.4 (64-bit) Enterprise Edition on a Linux (RHEL 5) PC. Java version is 1.6.0_20. Relevant .bash_profile environment variables are as follows:
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
    When I try to compile, I get:
    oracle:DB10204$ java FastConnect.java
    Exception in thread "main" java.lang.NoClassDefFoundError: FastConnect/java
    Caused by: java.lang.ClassNotFoundException: FastConnect.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: FastConnect.java. Program will exit.
    The java source code of one of the examples is below. Is someone able to point me in the right direction as to how I get this to compile? Do I just have a syntax and/or environment configuration modification to do, or is there more to it than that to get this example working? Any help much appreciated.
    oracle:DB10204$   cat FastConnect.java
    package OSBD;
    import java.sql.*;
    import oracle.jdbc.pool.OracleDataSource;
    public class FastConnect
      public static void main(String[] args)
        long connectTime=0, connectionStart=0, connectionStop=0;
        long connectTime2=0, connectionStart2=0, connectionStop2=0;
        ConnMgr cm = new ConnMgr();
        // time first connection. This connection initializes pool.
        connectionStart = System.currentTimeMillis();
        Connection conn = cm.getConnection("SCOTT");
        connectionStop = System.currentTimeMillis();
        String query = "select ename, job, sal from person_view";
        try {
          // show security by querying from View
          Statement stmt = conn.createStatement();
          ResultSet rset = stmt.executeQuery(query);
          while (rset.next()) {
            System.out.println("Name:   " + rset.getString(1));
            System.out.println("Job:    " + rset.getString(2));
            System.out.println("Salary: " + rset.getString(3));
          stmt.close();
          rset.close();
          // close the connection which resets the database session
          cm.closeConnection(conn);
          // time subsequent connection as different user
          connectionStart2 = System.currentTimeMillis();
          conn = cm.getConnection("KING");
          connectionStop2 = System.currentTimeMillis();
          // ensure database can distinguish this new user
          stmt = conn.createStatement();
          rset = stmt.executeQuery(query);
          while (rset.next()) {
            System.out.println("Name:   " + rset.getString(1));
            System.out.println("Job:    " + rset.getString(2));
            System.out.println("Salary: " + rset.getString(3));
          stmt.close();
          rset.close();
          cm.closeConnection(conn);
        } catch (Exception e)    { System.out.println(e.toString()); }
        // print timing results
        connectTime = (connectionStop - connectionStart);
        System.out.println("Connection time for Pool: " + connectTime + " ms.");
        connectTime2 = (connectionStop2 - connectionStart2);
        System.out.println("Subsequent connection time: " +
                            connectTime2 + " ms.");
    }Code download is at: http://www.mhprofessional.com/getpage.php?c=oraclepress_downloads.php&cat=4222
    I'm looking at Chapter 6.

    stuartu wrote:
    When I try to compile, I get:
    oracle:DB10204$  java FastConnect.java
    Exception in thread "main" java.lang.NoClassDefFoundError: FastConnect/java
    Caused by: java.lang.ClassNotFoundException: FastConnect.java
    I will try to explain what is happening here.
    You are launching java telling it to run a class named 'java' in a package named 'FastConnect'
    and java says it cannot find that class.
    What you intended to do:
    $ # make the directory structure match the package structure
    $ mkdir OSBD
    $ # move the source file in the directory structure so it matches the package structure
    $ mv FastConnect.java OSBD/
    $ # compile OSBD/FastConnect.java to OSBD/FastConnect.class
    $ javac OSBD/FastConnect.java
    $ # launch java using the OSBD/FastConnect class
    $ java -cp . OSBD.FastConnectNote that the package 'OSBD' does not follow the recommended naming conventions
    you might consider changing that to 'osbd'.

Maybe you are looking for