Can I query class created in current transaction?

I want to do the following:
manager.currentTransaction().begin();
manager.makePersistent(myObject);
Query q = manager.newQuery(myObject.getClass());
Collection objs = (Collection)q.execute();
manager.currentTransaction().commit();
and I want myObject to show up in the objects collection. Is there a way
to do that?
I thought of using read-uncommitted as the transaction isolation level,
but Oracle complained when I tried that.
Overrall what I'm trying to do is write unit tests such that I can set up
the test data, run the test, and rollback the transaction to clean it all
up.
Thanks!
-joel

It worked great.
This is just for code testing, so performance isn't critical.
Thanks!
Abe White wrote:
Set the query's IgnoreCache property to false:
q.setIgnoreCache (false);
You can also set this property at the PM level (affecting all queries
and extents from that PM) and the PMF level via the
javax.jdo.option.IgnoreCache setting (affecting everything).
However, note that if you are not ignoring PM cache changes and do not
set kodo.FlushBeforeQueries to true, we will have to perform the query
in-memory, which is a very slow process compared to database queries.

Similar Messages

  • Including uncommited data in extents from current transaction

    Is there a way to tell KODO to include uncommitted data in it's extent query
    results from the current transactions.
    i.e.
    Start Transaction
    find persistent object 1
    if not found run generic add persistent object 1 function
    find persistent object 1
    Make further changes to persistent object
    End Transaction

    Graham-
    Yes: set IgnoreCache to false. Queries and Extents will when pick up and
    new/modified instances in the cache.
    See the caveats in the docs, and control the performance with the
    FlushBeforeQueries configuration parameter.
    In article <bmmff7$mrr$[email protected]>, Graham Cruickshanks wrote:
    Is there a way to tell KODO to include uncommitted data in it's extent query
    results from the current transactions.
    i.e.
    Start Transaction
    find persistent object 1
    if not found run generic add persistent object 1 function
    find persistent object 1
    Make further changes to persistent object
    End Transaction
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Can not create follow up transaction FS Quotation from Lead in Interaction

    Dear All,
    We have requirement wherein IC agent should be able create FS Quotation (Transaction type FSO1) from Lead transaction type in WEB UI.
    I have made all the necessary cutomization for copy control. FS Quotation is also maintained for all chanel.
    Its work fine in CRM Online. I can create FS Quotation from Lead transaction type but in WEB UI when I click on Follow up button from Lead transaction pop will appear but I can not see FS Quotation in pop up window.
    What I found after investigation is that transaction type with Financial Contract as Leading business category can not be available for follow up from Lead in web ui but available in CRM online. When I change the leading business category to another one same transaction type can be seen for Follow up from Lead in web ui.
    Please let me know if you have any suggestion or faced similar kind of issue.
    Regards
    Pankaj Vispute

    Hello Pankaj,
    Yes, I have discovered this behavior as well. It seems to be documented in SAP Note 1172066. Apparently only the four following category classes are allowed:
    'A' : Interaction Log 
    'F' : Appointment     
    'G' : E-Mail          
    'H' : Task            
    Best regards,
    John

  • Can not create follow up transaction FS Quotation from Lead in WEB UI

    Dear All,
    We have requirement wherein IC agent should be able create FS Quotation (Transaction type FSO1) from Lead transaction type in WEB UI.
    I have made all the necessary cutomization for copy control. FS Quotation is also maintained for all chanel.
    Its work fine in CRM Online. I can create FS Quotation from Lead transaction type but in WEB UI when I click on Follow up button from Lead transaction pop will appear but I can not see FS Quotation in pop up window.
    Please let me know if you have any suggestion or faced similar kind of issue.
    Regards
    Pankaj Vispute

    Hello Pankaj,
    Yes, I have discovered this behavior as well. It seems to be documented in SAP Note 1172066. Apparently only the four following category classes are allowed:
    'A' : Interaction Log 
    'F' : Appointment     
    'G' : E-Mail          
    'H' : Task            
    Best regards,
    John

  • Creating a query that provides a default transaction type for those transactions not categorized?

    How could I create a query that provides a default transaction type for those transactions not categorized?
    So assuming I have:
    * Transactions table (with transactions)
    * Categories table
    * transactions_categories table - allows to allocate multiple categories (with a percentage)
     - tranactionID
     - categoryID
     - percentageAllocation
    * Usage is such that only non-personal categories have been applied through out data.  So there is a lot of transactions with no categories applied
    Aim:
    * Want to create a query that creates a list of all the allocated amounts, so would include as columns:  transaction.tDate, transaction.tTitle, categories.name, allocatedAmount(calculated from percentage * transaction amount)
    BUT:
    * How could I include in the query, the entries that cover all transaction that haven't been allocated, to a default category "personal", where the allocated Amount would be 100% of the transaction value
    * And also (if it were possible), for transactions that have been categorized but not for the complete transaction value (say only 50% was allocated to a category), how to to cover this off to.  

    To default the value of the category:
    select IIf(IsNull(Category),"Personal",Category) as Category,IIf(IsNull(Category),"100%",PercentageAllocation
    ) as PercentageAllocation from [yourtable]
    What do you want to put the values of these ones:
    And also (if it were possible), for transactions that have been categorized but not for the complete transaction
    value (say only 50% was allocated to a category), how to to cover this off to.  
    Fouad Roumieh

  • How can i create a SP transaction to make Dimension1 Mandatory

    Hi All
    How can i create a SP transaction to make Dimension1 Mandatory
    Best regards
    Rashid

    Dear Rashid,
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    ALTER proc [dbo].[SBO_SP_TransactionNotification]
    @object_type nvarchar(25),                     -- SBO Object Type
    @transaction_type nchar(1),     -- [A]dd, <u>pdate, [D]elete, [C]ancel, C[L]ose
    @num_of_cols_in_key int,
    @list_of_key_cols_tab_del nvarchar(255),
    @list_of_cols_val_tab_del nvarchar(255)
    AS
    begin
    -- Return values
    declare @error  int                    -- Result (0 for no error)
    declare @error_message nvarchar (200) -- Error string to be displayed
    select @error = 0
    select @error_message = N'Ok'
    IF (@object_type = '30' AND @transaction_type= 'A')
    BEGIN
    IF EXISTS (SELECT DocEntry FROM [dbo].[JDT1] WHERE (ProfitCode IS NULL OR ProfitCode = '') AND DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    SELECT @error =1, @error_message = 'Profit Center cannot be blank -Enter Plant Code'
    END
    END
    select @error, @error_message
    END
    Jeyakanthan

  • Can't query, create table in WAS

    hi everyone:
    I encounted a problem when I query a table in WAS.
    I find if I create a table by SAPDB console, then when I query that table in WAS. It always tells me "can't find that table". If I create and delpoy table by netweaver studio dictionary prospective, then I can query that table successfully in WAS. Anther thing is that I can't create a table by sql "create table..." in WAS. It always throws Exception likes below:
    com.sap.sql.log.OpenSQLException: The SQL statement "CREATE TABLE "TEST2" ("C_NAME" VARCHAR(20) UNICODE DEFAULT ' ' )" contains the syntax error[s]: Open SQL syntax error: CREATE ... TABLE is not supported
    SQL syntax error: "VARCHAR" is a reserved keyword and cannot be used as an unquoted identifier
    I think maybe SAP WAS using open sql causes those Exception. Can someone tell me how to create a table in java program when I use open sql? Can I query tables which are not deployed by NetWeaver studio dictionary?
    thanks
    elliot

    Hi,
    Please take a look at the Java persistence documentation:
    http://help.sap.com/saphelp_nw04/helpdata/en/87/773a55f35a65409009e87261c84eb2/frameset.htm
    Regards,
    Christian

  • On Amex web site, can not down load my current transactions. Work fine with IE.

    I can view my current transactions, but the download tab does not work. I call Amex and they are aware of the problem and said it was a FireFox problem to fix. IE work fine.

    Since it is a firefox problem our team should be in the know about if not already. I will file a bug for you. But first is there an error message that goes with it or what happens when you try to click on the download tab. Thanks!

  • Not flushing changes made in current transaction

    I encounter a problem that KODO doesn't flush changes made in current
    transaction. I'm using an external transaction manager (JOTM) and XA
    datasource (xapool). From the console output, I know I have an active
    transaction. According to the KODO automatic flush behaviour
    (http://solarmetric.com/Software/Documentation/3.1.2/docs/ref_guide_dbsetup_retain.html),
    given kodo.FlushBeforeQueries is true and kodo.ConnectionRetainMode is
    transaction, flush should happen before query.
    The code is something like this:
    userTransaction.begin();
    String field1 = "abc";
    long field2 = 10L;
    String field3 = "123";
    Foo foo = new Foo(); // Foo's PK is field1, field2 and field3.
    foo.setField1(field1);
    foo.setField2(field2);
    foo.setField3(field3);
    foo1(foo);
    Collection foos = foo2(field1, field2);
    System.out.println("foos.isEmpty()? : " + foos.isEmpty());
    userTransaction.commit();
    public void foo1(Foo foo)
    PersistenceManager pm = null;
    try
    pm = getPersistenceManager();
    System.out.println("PM.TX: " + pm.currentTransaction() + " active:
    " + pm.currentTransaction().isActive());
    pm.makePersistent(foo);
    catch (ResourceException e)
    e.printStackTrace();
    finally
    if (pm != null && !pm.isClosed())
    pm.close();
    public Collection foo2(String field1, long field2)
    PersistenceManager pm = null;
    StringBuffer filter = new StringBuffer();
    HashMap parameters = new HashMap();
    StringBuffer paramList = new StringBuffer();
    Extent ex = null;
    Query query = null;
    Collection result = null;
    Collection result1 = new ArrayList();
    Long field2Long = new Long(field2);
    try
    pm = getPersistenceManager();
    System.out.println("PM.TX: " + pm.currentTransaction() + " active:
    " + pm.currentTransaction().isActive());
    ex = pm.getExtent(Foo.class, true);
    filter.append("field1 == paramField1");
    filter.append(" && field2 == paramField2");
    paramList.append("String paramField1");
    paramList.append(" , Long paramField2");
    parameters.put("paramField1", field1);
    parameters.put("paramField2", field2Long);
    query = pm.newQuery(ex, filter.toString());
    query.declareParameters(paramList.toString());
    result = (Collection) query.executeWithMap(parameters);
    catch (ResourceException e)
    e.printStackTrace();
    finally
    if (pm != null && !pm.isClosed())
    pm.close();
    return result;
    From the console,
    PM.TX: kodo.runtime.PersistenceManagerImpl@b34b1 active: true
    PM.TX: kodo.runtime.PersistenceManagerImpl@b34b1 active: true
    foos.isEmpty()? true
    If the userTransaction is committed before invoking foo2(), then, the Foo
    object is created and foos.isEmpty() returns false.
    I am using KODO version: 3.1.2. Here is the kodo.properties:
    javax.jdo.PersistenceManagerFactoryClass:
    kodo.jdbc.runtime.JDBCPersistenceManagerFactory
    javax.jdo.option.Optimistic: true
    javax.jdo.option.RetainValues: true
    javax.jdo.option.NontransactionalRead: true
    javax.jdo.option.ConnectionFactoryName: jdbc/datasource
    javax.jdo.option.IgnoreCache: false
    kodo.Connection2UserName: <some user>
    kodo.Connection2Password: <some password>
    kodo.Connection2URL: jdbc:oracle:thin:@<some host>:1521:<some db>
    kodo.Connection2DriverName: oracle.jdbc.driver.OracleDriver
    kodo.jdbc.DataSourceMode: enlisted
    kodo.jdbc.ForeignKeyConstraints: true
    kodo.FlushBeforeQueries: true
    kodo.ConnectionRetainMode: transaction
    kodo.jdbc.VerticalQueryMode=base-tables
    kodo.TransactionMode: managed
    kodo.ManagedRuntime :
    invocation(TransactionManagerMethod=foo.TransactionManagerUtil.getTransactionManager)
    kodo.jdbc.DBDictionary : oracle(BatchLimit=0)
    Any ideas are appreciated.
    Regards,
    Willie Vu

    Abe White wrote:
    Do you get the same behavior with local transactions?
    I don't see anything immediately wrong with your code, but all our internal
    tests are passing, and no other user has reported a problem.In a single transaction, I'm using multiple persistence managers which are
    closed after usage (method foo1() and foo2() gets different persistence
    managers and close them before return). I don't think I can use local
    transactions, can I?

  • An Invalid Setup has been detected for the current Transaction Type in AME

    Gurus,
    I am constantly getting an error An Invalid Setup has been detected for the current Transaction Type in Approvals Management
    My client have 3 units say A,B,C. A requirement is such that whenever a vacancy is created, an approval should be sought from units HR manager.
    I have created a dynamic query for this and it is working fine for first two units say A & B. i.e. whenever somebody from unit A or B creates a vacancy it is correctly fetching the
    respective units managers. But, this whole AME is not working for unit C. An error pops out which says *An Invalid Setup has been detected for the current Transaction Type in
    Approvals Management* . Can anybody tell me what can be the issue?
    Edited by: 919527 on Aug 8, 2012 12:40 AM
    Edited by: 919527 on Aug 8, 2012 12:41 AM

    Solved it. The cursor wsa fetching two rows in plcae of one.

  • Creating standard roles transaction

    Hello,
    Please let me know transaction code of standard roles creation in SAP Business Workflow.
    Regards,
    Amey

    Create Roles 
    The role also contains the authorizations users need to access the transactions, reports, web-based applications and so on, contained in the menu.
    You can assign a role to an unlimited number of users.
    Procedure
    To create a single role:
    1.     Choose the pushbutton Create role or the transaction PFCG in the initial transaction SAP Easy Access. You go to the role maintenance.
    2.     Specify a name for the role.
    The roles delivered by SAP have the prefix 'SAP_'. Do not use the SAP namespace for your user roles.
    SAP does not distinguish between the names of simple and composite roles. You should adopt your own naming convention to distinguish between simple and composite roles.
    3.     Choose Basic maintenance (in the Profile, Other objects menu).
    4.     Choose Create.
    5.     Enter a meaningful role description text. You can describe the activities in the role in detail.
    You may use an existing role as a reference.
    6.     Assign transactions, programs and/or web addresses to the role in the Menu tab. The user menu which you create here is called automatically when the user to whom this role is assigned logs on to the SAP System. You can create the authorizations for the transactions in the role menu structure in the authorizations tab.
    If you want to call the transactions in a role in another system, enter the RFC destination of the other system in the Target system field.
    You should only use RFC destinations which were created using the Trusted System concept () to guarantee that the same user is used in the target system. This is only necessary if you want to navigate via the Easy Access Menu in the SAPgui.
    If you use the Workplace Web Browser, you can use any destination containing a logical system with the same name.
    If the Target system field is empty, the transactions are called in the system in which the user is logged on.
    You can also specify a variable which refers to an RFC destination. Variables are assigned to the RFC destinations in the transaction SM30_SSM_RFC.
    To distribute the role into a particular target system, specify the target system (its Release must be 4.6C) and choose Distribute. This function is most useful when you use the Workplace.
    You can create the user menu:
    o     from the SAP menu
    You can copy complete menu branches from the SAP menu by clicking on the cross in front of it in the user menu. Expand the menu branch if you want to put lower-level nodes or individual transactions/programs in the user menu.
    o     from a role
    this function copies a defined role menu structure in the same system into the current role. You can also copy the menu structure of a role delivered by SAP. Click on the menu branches and copy them.
    o     from an area menu
    You can copy area menus (SAP Standard and your own) into a role menu. Choose an area menu from the list of menus and copy the transactions you want.
    o     Import from file
    See Upload/Download roles.
    o     Transaction
    You can put a transaction code in the user menu directly.
    o     Program
    This function puts programs, transaction variants or queries in the user menu. They need not be given a transaction code.
    ABAP Report
    Choose a report and a variant. You can skip the selection screen.
    You can generate a transaction code automatically and copy the report description by setting checkboxes.
    SAP Query
    Enter a user group and query name. If the query has a variant, you can specify it. You can also specify a global query. See  Query work areas.
    Transactions with variants
    The system administrator can create transaction variants in the SAP System  Personalization. Transaction variants adjust complex SAP System transactions to customer business processes, by e.g. hiding superfluous information and adding other information such as pushbuttons, text or graphics. You can put a transaction variant call in a user menu by entering the transaction code and variant which you created in the transaction SHD0.
    BW report
    Include a Business Information Warehouse report. Enter the report ID.
    ReportWriter, Search, Report
    These function put other application-specific report types in the user menu.
    o     Others
    Enter other objects:
    Web address or file
    Enter internet/intranet links with a descriptive text and the web address. You can enter a file name if the browser can call an application.
    Drag and relate component
    Enter the component name.
    Knowledge Warehouse link
    Use the Document field possible entries help. Choose the information object type. You go to a selection screen in which you can search for the object in the Knowledge Warehouse.
    There are other pushbuttons for editing the user menu. Choose a menu entry with the cursor before you call one of the following functions.
    Function:     Meaning
      Create folder
    Group transactions, programs, etc. in a folder
      Change node text
    Change a menu entry text
      Move down
    Move a menu entry down one place
      Move up
    Move a menu entry up one place
      Delete nodes
    Delete a menu entry
    Any subnodes are also deleted.
      Delete all nodes
    Delete the complete role menu
      Translate node
    Translate a menu entry
      Documentation
    Display the documentation of transactions, programs, etc.
      Find doc.
    Find programs
    You can restructure the menu by Drag & Drop.
    The Menu tab status is red if no menu nodes are assigned. If at least one menu node is assigned, the status is green.
    You can assign Implementation Guide (IMG) projects or project views to a role under Utilities &#61614; Customizing auth. Do this to generate IMG activity authorization and assign users. The authorization to perform all activities in the assigned IMG projects/project views is generated in profile generation. You make the assignments in a dialog box. Choose Information to display more information on using this option.
    7.     Save your entries.
    You have created a role.

  • Database DAO - JDBC Query Class - Code review please

    I use the following class (Database.java) as a DAO for handling all database calls. The class works. You can use this if you're looking for a DAO solution (i.e. a way to query databases using connection pools / JNDI). I am looking for some suggestions on improving this class. Can you help? I.e. suggestions for improving SELECT speed, logic? The class is used by a moderately heavily used Web application (ca. 2000 - 3000 queries a day - so not too much) on a Sun Web Server system.
    This class had the following interfaces:
    getErrors() // for retrieving any errors that occurred during an query
    setSql() // one way to set the SQL that must be run
    setDbName() // one way to set the JNDI name of the database resource
    getInsertDelete() // run the INSERT/DELETE statement that was provided with setSql
    getInsertDelete(String givenSql, String givenDb) // run with provided sql and db
    getClobInsert(String givenSql, String givenDb, Hashtable clobHash, String identifierSql) // clobHash contains the column name and the value (which is a string over 4000 chars). Identifier SQL is the SQL for identifying the row, into which the Clob must be inserted. This interface is specific to Oracle.
    getSelect() // Query database with set SQL. Return as a vector of hashes so I can close connection.
    getSelect(String givenSql, String givenDb) // select with given sqlAnd here is the full class. I know, this is a weird post, but we don't really have a code review process here at work, and I don't have a specific problem. Just want some feedback concerning the way I query our databases. So, any tips or comments are welcome.
    package melib.network;
    import java.io.Writer;
    import java.io.StringReader;
    import java.io.IOException;
    import java.util.Vector;
    import java.util.Hashtable;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.Clob;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    import melib.system.PropertiesReader; // This is just a simple class for pulling values from a .properties file
    * Manages database connections.
    * @author jetcat33
    * @version 2.0, 2006-07-09
    public class Database {
        protected String sql = "";
        protected String dbName = "";
        private StringBuffer errors = new StringBuffer();
        /** Creates a new instance of Database */
        public Database() {
         * Check completeness of data
         * for example to check if dbname given or
         * sql given or to make sure that yikes
         * used instead of sccweb in test conditions
        protected boolean checkData(){
            if(dbName.equals("") || sql.equals("")){
                Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database]","No database selected for query (db: "+dbName+" or sql not included (sql: "+sql+")");
                setErrors("No database selected for query (db: "+dbName+" or sql not included (sql: "+sql+")");
                return false;
            }else{
                return true;
         * Sets and gets errors resulting from
         * exceptions - otherwise would have to
         * somehow include errors in the results
         * that are returned but that would include
         * other more complicated stuff.
        private void setErrors(String e){
            errors.append("\n"+e);
        public StringBuffer getErrors(){
           return errors;
         * Setter for the sql variable.
         * @param givenSql The sql required to process
        public void setSql(java.lang.String givenSql) {
            sql = givenSql;
         * Sets the dbName needed to commect
         * to the correct database.
         * @param givenDbName Name of the database - name and connections specified within this class
        public void setDbName(java.lang.String givenDbName) {
            dbName = givenDbName;
         * Processes Insert and Delete requests with given SQL and DB Name.
         * @param givenSql
         * @param givenDbName
         * @return String Number of rows affected
        public String getInsertDelete(String givenSql, String givenDbName){
            sql = givenSql;
            dbName = givenDbName;
            return getInsertDelete();
         * Takes care of insert, update and delete requests.
         * Must have set both dbName as well as the sql String.
         * Will return number of rows affected as String.
         * @return String Number of rows affected
         * @exception Exception
        public String getInsertDelete() {
            int returnValue = 0;
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        stmt = conn.createStatement();
                        returnValue = stmt.executeUpdate(sql);
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getInsertDelete]","getInsertDelete Exception: "+e.toString()+"\nWith: "+sql);
                    setErrors(e.toString());
                }finally{
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
            return returnValue+"";
         * Processes Insert requests for SQL containing CLOBS
         * @param givenSql
         * @param givenDbName
         * @param clobHash Contains column name of clob and clob text
         * @param identifierSql Contains SQL to identify the just entered SQL so the clobs can be filled in.
         * @return String Number of rows affected
        public String getClobInsert(String givenSql, String givenDbName, Hashtable clobHash, String identifierSql){
            sql = givenSql;
            dbName = givenDbName;
            String returnValue="";
            int rv = 0;
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        conn.setAutoCommit(false);
                        stmt = conn.createStatement();
                        rv = stmt.executeUpdate(sql); // write first time
                        // Now get and overwrite "EMPTY_CLOB()"
                        ResultSet lobDetails = stmt.executeQuery(identifierSql);
                        ResultSetMetaData rsmd = lobDetails.getMetaData();
                        if(lobDetails.next()){
                            for(int i = 1; i <= rsmd.getColumnCount(); i++){
                                if(clobHash.get(rsmd.getColumnName(i))!=null && !clobHash.get(rsmd.getColumnName(i)).equals("")){
                                    Clob theClob = lobDetails.getClob(i);
                                    Writer clobWriter = ((oracle.sql.CLOB)theClob).getCharacterOutputStream();
                                    StringReader clobReader = new StringReader((String) clobHash.get(rsmd.getColumnName(i)));
                                    char[] cbuffer = new char[30* 1024]; // Buffer to hold chunks of data to be written to Clob, the slob
                                    int nread = 0;
                                    try{
                                        while((nread=clobReader.read(cbuffer)) != -1){
                                            clobWriter.write(cbuffer,0,nread);
                                    }catch(IOException ioe){
                                       //System.out.println("E: clobWriter exception - " + ioe.toString());
                                    }finally{
                                        try{
                                            returnValue+=" Writing: "+rsmd.getColumnName(i);
                                            clobReader.close();
                                            clobWriter.close();
                                        }catch(IOException ioe2){
                                            //System.out.println("E: clobWriter close exception - " + ioe2.toString());
                        conn.commit();
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getClobInsert]","getClobInsert Exception: "+e.toString()+"\nWith: "+sql+"\nAND\n"+identifierSql);
                    setErrors(e.toString());
                }finally{
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
                returnValue=rv+" "+returnValue;
            return returnValue;
         * Takes care of Select statements.
         * Must have set both dbName as well as the sql String.
         * Will return a vector.
         * @return Vector of Hashes containing the Results of the query
         * @exception SQLException
         * @exception Exception
        public Vector getSelect(){
            Vector returnValue = new Vector();
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                ResultSet result = null;
                ResultSetMetaData rsmd = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        stmt = conn.createStatement();
                        result = stmt.executeQuery(sql);
                        rsmd = result.getMetaData();
                        while(result.next()){
                            Hashtable hash = new Hashtable();
                            for(int i = 1; i <= rsmd.getColumnCount(); i++){
                                if(result.getString(i) != null){
                                    hash.put(rsmd.getColumnName(i),result.getString(i));
                                }else{
                                    hash.put(rsmd.getColumnName(i),"");
                            returnValue.addElement(hash);
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getSelect]","getSelect Exception: "+e.toString()+"\nWith: "+sql);
                    setErrors(e.toString());
                }finally{
                    try{
                        result.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                       setErrors(e.toString());
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
            return returnValue;
         * Takes care of Select statements with given SQL.
         * Must have set both dbName as well as the sql String.
         * Will return a vector.
         * @return Vector with Results of the query
         * @exception SQLException
         * @exception Exception
        public Vector getSelect(String givenSql, String givenDbName){
            sql = givenSql;
            dbName = givenDbName;
            return getSelect();
    }Thank you,
    dailysun

    too much code that's repeated. refactor all the code you have for closing resources into a utility class and simply call its methods.
    your dao creates the connection, so it can't participate in a transaction. if there are several daos that should be one unit of work, you can't manage it with this framework.
    transactions are under the control of a service layer. I think it's better to have the service object get the connection, pass it to all the DAOs needed for that unit of work, and then have the service close it.
    e-mailing errors? I don't like it. if you have 2-3K queries a day failing because the database you'll have 2-3K e-mails to delete. better to log messages. if you really want e-mail, you can have Log4J add an e-mail appender. at least that way it's configurable outside the code.
    CRUD operations without an UPDATE? You're missing something important.
    What if I don't want to get the database from a JNDI datasource? Now you can't use this DAO without an app server.
    Your error messages are less informative than a stack trace. Why not throw an exception with detailed info?
    have a look at Spring and how it handles persistence. if you insist on writing your own, might want to look at Spring. Rod Johnson has developed a much better, more general way to handle persistence.
    http://www.springframework.org
    You return a Vector of Hashtables for queries? Two old-school data structures. You understand the implication of choosing those, right? I'd recommend that you change that to a List of Maps. Let the concrete types be ArrayList and HashMap. Interfaces are preferred, because they let you change the implementation without affecting clients. Vector and Hashtable are synchronized by default; ArrayList and HashMap are not. Synchronization is thread safe but slower.
    I understand why you chose to return Vector, because you wanted something general that wouldn't force you to deal with object-relational mapping. This way you can just worry about ResultSetMetaData.
    A Vector of Hashtables is a row-based view of the ResultSet (one Hashtable per row). Sometimes a column based view can be more convenient. Then it's a Map of Lists.
    You gave it a good try, but I think there's a lot of room for improvement.
    %

  • Problem:Can't instantiate class

    I tried for many hours to solve the problem but in vain.
    here is the Exception i got from tomcat:javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'core.walid.NwindManagedBean'.. core.walid.NwindManagedBean
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:844)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:91)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    cause m�re
    javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'core.walid.NwindManagedBean'.. core.walid.NwindManagedBean
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
         javax.faces.component.UIData.getValue(UIData.java:527)
         javax.faces.component.UIData.getDataModel(UIData.java:856)
         javax.faces.component.UIData.setRowIndex(UIData.java:379)
         com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:65)
         javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
         javax.faces.component.UIData.encodeBegin(UIData.java:681)
         javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)
         javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:543)
         com.sun.faces.taglib.html_basic.DataTableTag.doEndTag(DataTableTag.java:491)
         org.apache.jsp.index_jsp._jspx_meth_h_dataTable_0(index_jsp.java:161)
         org.apache.jsp.index_jsp._jspx_meth_c_view_0(index_jsp.java:116)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:80)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)here is the bean i don't see any problelme it uses JDBC to access the database/*
    * NwindManagedBean.java
    * Created on 4 mars 2007, 01:02
    package Core.walid;
    import java.sql.*;
    import javax.sql.*;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.io.*;
    import javax.servlet.jsp.jstl.sql.*;
    * @author walid
    public class NwindManagedBean implements Serializable{
        private String tableName="Customers";
        private ResultSet resultSet;
        private Connection connection;
        /** Creates a new instance of NwindManagedBean */
        public NwindManagedBean() {
        public String getTableName(){
        return tableName;
        public void setTableName(String tableName){
        this.tableName=tableName;
        public void open(){
        String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
        String url = "jdbc:odbc:Nwind";
        String username = "";
        String password = "";
        try{
            Class.forName(driver);
            connection =DriverManager.getConnection(url,username,password);}
        catch(Exception e){System.out.println(e);}
        public void search(){
          try{ Statement statement=connection.createStatement();
           String query ="select * from "+tableName;
            resultSet=statement.executeQuery(query);
        catch(Exception cnfe) {};
        public ResultSet getResultSet(){
            open();
            search();
            return resultSet;
        public void showResults(){
            int i=1;
           try{ while(resultSet.next())
            System.out.println(resultSet.getString(i));
            i++;
           catch(Exception e){System.out.println("erreur sql"+e);}
    }i declared the bean in faces-config<faces-config>
        <managed-bean>
            <managed-bean-name>NwindManagedBean</managed-bean-name>
            <managed-bean-class>core.walid.NwindManagedBean</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
    </faces-config>and finally the jsf page to list the database contents<%@ taglib uri="http://java.sun.com/jsf/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <html>
       <HEAD><TITLE>Northwind Customers</title>
        </HEAD>
        <body>
            <center>
                <table border="5">
                    <tr><th class="Northwind customers"></th></tr>
                </table>
                <p>
                <c:view>
                    <h:dataTable value="#{NwindManagedBean.resultSet}"
                    var="dbRow"
                    border="1"
                    >
                    <h:column>
                    <c:facet name="header">
                    <c:verbatim>Company name</c:verbatim>
                    </c:facet>
                    <h:outputText value="#{dbRow.CompanyName}"/>
                    </h:column>
                    <h:column>
                    <c:facet name="header">
                    <c:verbatim>Address</c:verbatim>
                    </c:facet>
                    <h:outputText
                    value="#{dbRow.Address}"/>
                    </h:column>
                    <h:column>
                    <c:facet name="header">
                    <c:verbatim>City</c:verbatim>
                    </c:facet>
                    <h:outputText
                    value="#{dbRow.City}"/>
                    </h:column>
                    </h:dataTable>
                </c:view>
                </center>
        </body>
    </html>

    Hello,
    I'm not sure, but i would try to put the package only in lowercase.
    Your class pakageis declared with first Upper case letter.
    And in you faces-config file, you declared with lower case.
    Note : it's recommanded to use only lower case for package name.
    Regards,
    Sebastien Degardin

  • Re:- XMII is there a way todynamically create local or transaction variable

    Dear all,
    Is there a way to create local or transaction variable dynamically inside the BLS transactions.
    I have a scenario where in i am reading the XMl document and based on the number of node (sub node ) items i need to temporary save those values into transaction variable .  I want to use these saved transaction variable tvalues o later insert into database

    After reading your second post, I wonder why you want to temporarily store the separate values from the XML node in a local property.
    If you already have all values available in a XML, than it would be easier to process the XML directly in MII, as that is what MII does best. MII can directly access the node values and use it as input for your databse inserts. Using a repeater action, you can process 0 to n nodes. Use XPath to transfer the node values to the query parameters.
    Is this the option you are looking for, or do I miss something?
    Michael

  • Creating "Payables Account Transaction" using custom code

    Hi Gurus,
    I need a help. I have a requirement that I have to create "Payables Account Transaction" using custom PL/SQL code. Kindly could you advise me as to which API or Package should i use to get this done. Currently I am in 11.5.10.2.
    Pls help me on this.
    Thanks,
    Genoo

    Hi Genoo,
    As mentioned I would reverse the standard journals coming from Payables, that way you can still see what the original journals were and drill back using them. So you don't do anything in the subledger.
    Alternatively if you wanted to get more risky, when you run the Payables transfer to GL, you could choose not to submit journal import and then you could manipulate the AP Journal records while they are still in the GL_INTERFACE (as they also go through that table) prior to going to GL, then you could do whatever you want - and if you don't delete them (but update / copy them) they will still retain the drilldown links back to AP.
    Regards,
    Gareth

Maybe you are looking for

  • What is the new 'plug-in failure' with iWeb videos?

    I'm trying to update my iWeb 2.0.4 into the current 3.0.4, and I download all the fixes, and the last version doesn't allow an upgrade... do I just need to go to a store and get a disc?  When I try to find iWeb as an app, it disappears between iWork

  • BB phone won't recognize it is in WIFI zone

    Hello, My BB Storm has connected to the WIFI network here in England while I am visiting, but when I try to retrieve my emails or send texts, it give this message: 'Your connection to the mobile network is turned on, but you are not in a wireless cov

  • Fixed Custom serial number in SSRS

    hello all, I am here to find solution where i want to fixed a serial number with my particular data row. i my report i want to assign a fixed row number to row which will not be change if number of rows affected by filter . i meant.. SR      Employee

  • BEx Designer: How to count if an InfoObject(field=ProblemNr)  is empty

    Hi, in the ROWS i have an InfoObject (let's say ProblemNumber) and in the COLUMNS another InfoObject (Date). The IO in the Rows is not a primary key and it's not always filled in. The OrderNr might be a primary key. I want to find out how many of the

  • Cisco Prime Infrastructure 1.2 OVA - URL/FTP not working

    The ESXi install of the theNCS  OVA was successful. NCS seems to load and activate interfaces. The console session is working. Using compliant browsers; https://<ip address> does not work. When I stop "ncs" or halt the vm the web page responds shortl