Delete from Database?

How do you delete a row from a database. I have 2 columns (user and password)in the Database so far with 4 records. I have constructed a frame with 4 radiobuttons and a jbutton. I want the program to delete for example the first record if the first radiobutton is selected. I am nearly there but I need a little help.I am struggling with the SQL code needed.
here is what i've done so far:
public void deleteser(){
String rdsn = "jdbc:borland:dslocal:C:\\JBuilder6\\bin\\userinfo.jds";
String rdbUser = "Adham";
String rdbPass = "reqs";
try {
Connection cons = DriverManager.getConnection(rdsn, rdbUser, rdbPass);
Statement stmnt = cons.createStatement();
String query = "SELECT*FROM Users"; // Users is the name of the table
ResultSet rs = stmnt.executeQuery(query); // ResultSet object to hold the result of the query
//int cnt = 0;
while (rs.next()) {                                                                                       String s = rs.getString("User");
String p = rs.getString("Password");
//cnt++;
if (duser1.isSelected()){
break;}
else if (duser2.isSelected()){
break;}
else if (duser3.isSelected()){
break;}
else if (duser4.isSelected()){
break;}
else if (duser5.isSelected()){
break;}
rs.close();
stmnt.close();
cons.close();
} catch (Exception e) {
e.printStackTrace();
return;

Still unable to do it, this is how it looks now:
public void deleteser(){
String rdsn = "jdbc:borland:dslocal:C:\\JBuilder6\\bin\\userinfo.jds"; // the odbc address of the DB.
String rdbUser = "Adham"; // the user account to the DB.
String rdbPass = "reqs"; // password for the dbuser.
try {
Connection cons = DriverManager.getConnection(rdsn, rdbUser, rdbPass); // gets a connection to the DB
Statement stmnt = cons.createStatement();
Statement instmnt = cons.createStatement(); // get a statement which can execute the sql-code
String query = "SELECT * FROM Users"; // Users is the name of the table
ResultSet rs = stmnt.executeQuery(query); // ResultSet object to hold the result of the query
int cnt = 0;
while (rs.next()) {                                                   // 'next' takes you down to the next row of the DB
String s = rs.getString("User");
String p = rs.getString("Password");
cnt++;
if (cnt==1 && duser1.isSelected()){
String sql = ("DELETE FROM USERS VALUES ('"+ s + "','"+ p +"')");
instmnt.executeUpdate(sql);}
else if (cnt==2 && duser2.isSelected()){
String sql = ("DELETE FROM USERS VALUES ('"+ s + "','"+ p +"')");
instmnt.executeUpdate(sql);}
else if (cnt==3 && duser3.isSelected()){
String sql = ("DELETE FROM USERS VALUES ('"+ s + "','"+ p +"')");
instmnt.executeUpdate(sql);}
else if (cnt==4 && duser4.isSelected()){
String sql = ("DELETE FROM USERS VALUES ('"+ s + "','"+ p +"')");
instmnt.executeUpdate(sql);}
else if (cnt==5 && duser5.isSelected()){
String sql = ("DELETE FROM USERS VALUES ('"+ s + "','"+ p +"')");
instmnt.executeUpdate(sql);}
rs.close();
stmnt.close();
cons.close();
} catch (Exception e) {
e.printStackTrace();
return;

Similar Messages

  • ADF delete from database.

    Hi,
    I am trying to design a page which will delete a particular row from one or more database tables. The jdeveloper version is 11.5 and the database is oracle 10.2 version.
    How can I do it?
    Thanks

    Hi all, Thanks for the reply..
    Actually I am trying to delete one record at a time, from the same table, from which m populating it on the jspx..
    That means the list source and the base source are same..which is not possible..
    What can be the solution for it ??
    I tried to create a separate view object for population on jspx and kept it in list source.. And I am using different view object in base source.. Both view objects refer to the same table..
    But it is not working out..the problems are..
    The record is getting deleted only for the first time when i run it.. Even after getting deleted from database, the record shows up in the list..
    And when i do the same operation one more time in the same session, 1st record in the table is getting updated with the value which i tried to delete..
    And I am not using managed bean..
    regards

  • DELETE FROM DATABASE + restored again?

    there is a statement
    DELETE FROM DATABASE <dbtab> (<ar>) [CLIENT <cli>]
    ID <key> .
    Suppose I have mistakenly deleted from the database
    can it be

    Hi,
    there is a syntax like DELETE FROM DATABASE as you mentioned.
    But never ever use that to delete a record in DATABASE TABLE as you cannot recover that data.
    hope this helps.

  • Dynamic record deletion from database table

    Hi,
    I need to delete selected records from database table(dynamic names). Table names are being passed from main program with some of their field names. The record to be deleted from the database table is being decided based on the fields passed for the table and their contains passed from the main program.
    It is not possible to write dynamic where clause for DELETE statement directly.
    So, I created a dynamic internal table and i am trying to fetch all records using SELECT statement(for which we can write dynamic where condition, something like...SELECT...WHERE (itab).  ) which need to be deleted in the iternal table.
    Piece of code :
              CONCATENATE c_im v_tablefield1 INTO v_imprtfield1.
              CONCATENATE v_tablefield1 c_in v_imprtfield1
                       into s_condition separated by space.
              APPEND s_condition TO t_condition.
              PERFORM GET_DYNAMIC_ITAB USING s_flds_agtab-tabname
                                    changing t_itab.
              ASSIGN t_itab->* TO <itab>.
    *Select the data (to be deleted) from the database table
               SELECT * FROM (s_flds_agtab-tabname) INTO TABLE <itab>
                 WHERE (t_condition).
    *Delete the records from the table
               IF SY-SUBRC = 0.
                 DELETE (s_flds_agtab-tabname) FROM TABLE <itab>.
               ENDIF.
    Here t_condition is of standard table of WHERETXT.
    t_condition at the run time before giving dump was:
    SPART IN IM_SPART
    AND KUNNR IN IM_KUNNR
    Here IM_SPART is renge type of SPART and IM_KUNNR is renge of KUNNR.
    I am getting a DUMP:
    The WHERE condition has an unexpected format.
    Error analysis                                                                               
    The current ABAP/4 program attempted to execute an ABAP/4 Open SQL
    statement containing a WHERE condition of the form WHERE (itab) or
    WHERE ... AND (itab). The part of the WHERE condition specified at
    runtime in the internal table itab contains the operator         
             IN (v1, ..., vn)                                        
    in incomplete form.                                              
    How to correct the error
    If the error occurred in a non-modified SAP program, you may be  
    able to find a solution in the SAP note system.                  
    If you have access to the note system yourself, use the following
    search criteria:                                                 
    "SAPSQL_IN_ILLEGAL_LIST"                               
    "SAPLZSD_TAB_REFRESH " or "LZSD_TAB_REFRESHU01 "       
    "Z_SD_REFRESH_AGTABLES"                                
    If you cannot solve the problem yourself, please send the
    following documents to SAP:                             
    I would like to know whether "IN" operator is allowed in (itab) of WHERE clause. While testing I changed the "IN" to "=" specifying a suitable value there. It worked. So please let me know if i can give "IN" operator using renge table in the dynamic where clause.
    Thanking you,
    Surya

    Hi again,  so if you can not use the IN in a dynamic where clause you might be forced to dynamically build the entire select statement,  Here is a sample program which may give you some ideas, notice that we are writing the select statement code, putting it in another program and generating the subroutine at runtime, then call this routine.  I'm sure that this will help you see what you need to do.
    report zrich_0003 .
    tables: kna1.
    types: t_source(72).
    data: routine(32) value 'DYNAMIC_SELECT',
                 program(8),
                 message(128),
                 line type i.
    data: isource type table of t_source,
                xsource type t_source.
    ranges:
            r_kunnr for kna1-kunnr.
    data: ikna1 type table of kna1.
    data: xkna1 type kna1.
    r_kunnr-sign = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low    = '0001000500'.
    append r_kunnr.
    xsource = 'REPORT ZTEMP.'.
    insert xsource  into isource index 1.
    xsource = 'FORM dynamic_select'.
    insert xsource  into isource index 2.
    xsource = 'Tables r_kunnr ikna1.'.
    append xsource to isource.
    xsource = 'select * into table ikna1 from kna1'.
    append xsource to isource.
    xsource = 'where kunnr in r_kunnr.'.
    append xsource to isource.
    xsource = 'ENDFORM.'.
    append xsource to isource.
    generate subroutine pool isource name program
                             message message
                             line line.
    if sy-subrc = 0.
      perform (routine) in program (program) tables r_kunnr
                                                    ikna1.
    else.
      write:/ message.
    endif.
    loop at ikna1 into xkna1.
      write:/ xkna1-kunnr.
    endloop.
    Regards,
    Rich Heilman

  • Delete from database Table

    Hi,
    To delete data from database table using internal table I am using following statement.
    DELETE dbtab       FROM TABLE itab.
    Itab is a sorted table.Just wondering if table type matters while deleting database entries using internal table.which is efficient table type for deleting records from database table?
    Regards
    Nilesh

    Hi Nilesh
    The row type of the internal table must be a data object with at least the same length and alignment as the key structure of the database table. The key is read according to the structure of the table line, and not that of the row type. It is a good idea to define the row type with reference to the structure of the database table.
    From SAP Help
    DATA: BEGIN OF WA,
    CARRID TYPE SPFLI-CARRID,
    CONNID TYPE SPFLI-CONNID,
    END OF WA,
    ITAB LIKE HASHED TABLE OF WA
    WITH UNIQUE KEY CARRID CONNID.
    WA-CARRID = 'UA'. WA-CONNID = '0011'.
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'LH'. WA-CONNID = '1245'.
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'AA'. WA-CONNID = '4574'.
    INSERT WA INTO TABLE ITAB.
    DELETE SPFLI FROM TABLE ITAB.
    Besides, it is so technical what algorithm is run to delete records from the DB table when an internal table is given. If you want you can have a quick test using GET TIME. However, it seems logical that if your internal table is sorted with respect to any index, especially the primary index, of the DB table this may increase performance.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • DELETE FROM database table takes more time...

    Hi Friends,
    The below statement takes more time.
    LOOP AT i_final.
      DELETE FROM zcisconec WHERE werks = i_final-werks
                              AND aufnr = i_final-aufnr
                              AND vornr = i_final-vornr.
    ENDLOOP.
    Internal table I_FINAL will have more than 80,000 records.
    DB Table zcisconec have 4 primary key fields out of 10 fields.
    Below 4 fields are primary key fields
    WERKS
    AUFNR
    VORNR
    MATNR
    Please guide me..How to optimize it?
    Regards,
    Viji

    HI,
    Check this one ,
    put a break point on that delete statement and add another line of code after, like .... CHECK SY-SUBRC = 0. Now got to debug and stop at the DELETE statement, check the number of records in your DB table, now hit F5 to step to the next statement, now go back to SE16 and refresh, do you see the number change? It should.........if you are selecting the data correctly, make sure that you are getting data into the IT_  table.
    DELETE zcisconec from i_final.
    CALL FUNCTION 'DB_COMMIT'.
    Regards,
    Ansari.
    Edited by: Ansari Samsudeen on Sep 15, 2009 8:14 AM

  • Request templete - is it possible to delete from database?

    Hi All,
    is it possible to delete/disable request template from OIM database after we use it to generate some request?
    best
    mp
    Edited by: J23 on 2012-02-17 05:48

    If can change configuration (delete) of request template any time, via UI, don't do it via sql query.
    http://docs.oracle.com/cd/E21764_01/doc.1111/e14316/req.htm#BABFJHDF
    If you are talking about deleting or changing request dataset, sure you can do it any time Again If you going to perform any MDS operation keep the backup of MDS.

  • Delete entry from Database table

    Hi,
    I configured one PCR scenerio in SPRO node -> business Packakes/ funtional packages-> Manager self service-> Personal Change request -> Group Change request scenerio.
    later I deleted that entry in backend, but still the same entry exist in db table "TWPC_PCR_Groups" .
    How can we delete that entry?
    thanks

    Hi,
    If you just want to delete a single entry from database table then you have to it in debug mode .
    go to se11->Give table name->Press F7( ie: display table entries)-> Goto the table contents (CTRLSHIFTF10)->Select the entry you want to delete->Give /H in the command bar ->enter into debug mode-> Give code as DELE -> save it. and press enter. Your entry will be deleted from database.
    Hope this helps..

  • Urgent -Create  RFC for update the database and delete from the database

    Hi Guy's,
    Please help me how  to create the RFC for update to databse and delete from database(step-by-step) procedure.
    Thanks and Regards,
    Sai.

    Hi,
    Please go through the following link,
    reward if helps.
    [RFC Step By Step|https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=39728]
    regards,
    mahantesh

  • EJB/JPA Related: Objects are not going to delete from a Collection

    Hi All,
    I am developing a WebDynpro application using EJB3 model with JPA as a persistence tool. I have mapped using Annotations.
    All other works run fine but If I deleted a record through view It will not delete from database.
    I have two entities : First : OperationDayWorkingCapitalPlan in which following relation is defined:
         @OneToMany(mappedBy="operationDayWorkingCapitalPlan",targetEntity=BranchPartyCollectionsPlan.class,
           fetch=FetchType.EAGER, cascade=CascadeType.ALL)
         private Collection<BranchPartyCollectionsPlan> branchPartyCollectionsPlans = new  
           ArrayList<BranchPartyCollectionsPlan>();
    related methods:
         public Collection<BranchPartyCollectionsPlan> getBranchPartyCollectionsPlans() {
              return branchPartyCollectionsPlans;
         public void setBranchPartyCollectionsPlans(
                   Collection<BranchPartyCollectionsPlan> branchPartyCollectionsPlans) {
              this.branchPartyCollectionsPlans = branchPartyCollectionsPlans;
         public void addBranchPartyCollectionsPlan(BranchPartyCollectionsPlan branchPartyCollectionsPlan) {
            this.branchPartyCollectionsPlans.add(branchPartyCollectionsPlan);
            if (branchPartyCollectionsPlan.getOperationDayWorkingCapitalPlan() == null || branchPartyCollectionsPlan.getOperationDayWorkingCapitalPlan() != this) {       
                 branchPartyCollectionsPlan.setOperationDayWorkingCapitalPlan(this);
         public void removeBranchPartyCollectionsPlan(BranchPartyCollectionsPlan branchPartyCollectionsPlan) {
              if (branchPartyCollectionsPlan == null)
                   return;
              if (this.branchPartyCollectionsPlans != null)
                   if (this.branchPartyCollectionsPlans.remove(branchPartyCollectionsPlan)) {
                        branchPartyCollectionsPlan.setOperationDayWorkingCapitalPlan((OperationDayWorkingCapitalPlan)null);
    and Second one is : BranchPartyCollectionsPlan in which the following relation(inverse) is defined:
    @ManyToOne(fetch=FetchType.EAGER)
         @JoinColumn(name="OPERATIONDAYWORKINGCAPITALPLANID")
         OperationDayWorkingCapitalPlan operationDayWorkingCapitalPlan
      related getter and setter:
         public OperationDayWorkingCapitalPlan getOperationDayWorkingCapitalPlan() {
              return operationDayWorkingCapitalPlan;
         public void setOperationDayWorkingCapitalPlan(
                   OperationDayWorkingCapitalPlan operationDayWorkingCapitalPlan) {
              OperationDayWorkingCapitalPlan oldOperationDayWorkingCapitalPlan = this.operationDayWorkingCapitalPlan;
              if (oldOperationDayWorkingCapitalPlan != null){
                   oldOperationDayWorkingCapitalPlan.removeBranchPartyCollectionsPlan(this);
              this.operationDayWorkingCapitalPlan = operationDayWorkingCapitalPlan;
              if (operationDayWorkingCapitalPlan != null){
                   operationDayWorkingCapitalPlan.addBranchPartyCollectionsPlan(this);
    Plz help me where am I wrong. Why objects(BranchPartyCollectionsPlan) from collection not delete when I merge the main object (OperationDayWorkingCapitalPlan).
    Edited by: kapitsu on Oct 27, 2009 10:24 AM

    Hi Mayank,
    You can check the below Link.
    PSA Not Deleting, error : DDL time(___1):.....0 milliseconds
    Regards
    Rahul

  • Reg:How to delete the column in table control also from database table.

    Hi Experts,
    Once again thank u all for giving the responses.
    one more doubt is how to delete the columns of table control and also the record shold delete from ztable.
    With Regards,
    Saroja.P.

    Hi,
    If you want to delete the rows in the table control and simultaneously delete it from the database table, then you can implement a 'DELETE' functionality specific to your table control. Have a MARK field (you will find that in the screen attributes of the table control -> give a name for the MARK field, you will find an additional MARK column at the beginning of your table control). You can check whatever rows you want to delete from the table control, call the delete module.
    "This portion of code inside the LOOP...ENDLOOP.
    IF sy-ucomm eq 'F_DELETE'.
       gt_itab2-check = mark.  " Store the MARK field status into your internal table's correspoding field 'check'
      MODIFY gt_itab INDEX tabcontrol-current_line.
    ENDIF.
    iF sy-ucomm eq 'DELETE1'.
      DELETE gt_itab WHERE check eq 'X'. "Your internal table does not have rows that you want to delete
    ENDIF.
    Now you can modify your database table using the MODIFY statement.
    MODIFY ZDB FROM TABLE gt_itab.

  • How to delete a row from database table in facade client

    Hi all,
    I followed the tutorial in creating a persistence entity from database table, then a session facade. Then I followed the tutorial to create a sample client to test the model. In the session facade, I could use persistEntity method to insert a record to the database. I am just thinking of an extension to the tutorial, i.e., being able to delete the record too. So I created a new method removeEntity in the session facade
    public void removeEntity(Object entity) {
    entity=em.merge(entity);
    em.remove(entity);
    em.flush();
    and called it in the sample client. It was executed without any error, but the record in the table still exists.
    I tried to look around for a solution, but I did not find one. Would anybody here please help out? Many thanks in advance!

    Hi Frank,
    I tried the code snippet, but I got the following exception when executing this code:
    javax.ejb.EJBException: EJB Exception: ; nested exception is:
         java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.; nested exception is: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
    java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:121)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
         at $Proxy141.getTransaction(Unknown Source)
         at model.SessionEJBBean.removeEntity(SessionEJBBean.java:60)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:55)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy143.removeEntity(Unknown Source)
         at model.SessionEJB_qxt9um_SessionEJBImpl.removeEntity(SessionEJB_qxt9um_SessionEJBImpl.java:142)
         at model.SessionEJB_qxt9um_SessionEJBImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    javax.ejb.EJBException: EJB Exception: ; nested exception is:
         java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.; nested exception is: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:109)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:91)
         at $Proxy0.removeEntity(Unknown Source)
         at model.SessionEJBClient.main(SessionEJBClient.java:71)
    Caused by: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:121)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
         at $Proxy141.getTransaction(Unknown Source)
         at model.SessionEJBBean.removeEntity(SessionEJBBean.java:60)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:55)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy143.removeEntity(Unknown Source)
         at model.SessionEJB_qxt9um_SessionEJBImpl.removeEntity(SessionEJB_qxt9um_SessionEJBImpl.java:142)
         at model.SessionEJB_qxt9um_SessionEJBImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Process exited with exit code 0.

  • HOW TO DELETE THE ROW FROM DATABASE

    hI,
    Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.
    thanks
    naveen
    [email protected]
    <%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,java.util.Vector,java.util.StringTokenizer" %>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Item Details</title>
    <script>
    function submitPage()
    document.details.action = "itemdetails.jsp" ;
    document.details.submit();
    </script>
    </head>
    <body>
    <form name="details" action="itemdetails.jsp" method="post">
    <%
    ConnectionPool pool;
    Connection con = null;
    Statement st;
    ResultSet rs =null;
    %>
    <table border="0" cellpadding="0" cellspacing="0" width="328">
    <tr>
    <td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
    <input type="submit" value="search" name="search" ></td>
    </tr>
    <tr>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item Code</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item No</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Amount </b></font></td>
    <td width="80" bgcolor="#000099"> </td>
    </tr>
    <%
    pool= new ConnectionPool();
    Utils utils = new Utils();
    double total =0.00;
    String search =utils.returnString(request.getParameter("search"));
    if(search.equals("search"))
    try
    String ref_no =utils.returnString(request.getParameter("txt_refno"));
    String strSQL="select * from ref_table where refno='" + ref_no + "' ";
    con = pool.getConnection();
    st=con.createStatement();
    rs = st.executeQuery(strSQL);
    while(rs.next())
    String itemcode=rs.getString(2);
    int item_no=rs.getInt(3);
    double amount= rs.getDouble(4);
    total= total + amount;
    %>
    <tr>
    <td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
    <td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
    <td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
    <td width="80"><a href="delete</td>
    </tr>
    <%
    }catch(Exception e){}
    finally {
    if (con != null) pool.returnConnection(con);
    %>
    <tr>
    <td width="323" colspan="4">
    <p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
    </tr>
    <tr>
    <td width="323" colspan="4">                   
    <input type="button" value="save" name="save"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    You mean when you click on the hyperlink you want that row to disappear from the page, but not delete the row from the database until a commit/submit button is pressed?
    Personally, I think I'd prefer that you have a delete checkbox next to every row and NOT remove them from the display if I was a user. You give your users a chance to change their mind about their choice, and when they're done they can see exactly which rows will be deleted before they commit.
    You know your problem, of course, so you might have a good reason for designing it this way. But I'd prefer not removing them from the display. JMO - MOD

  • How can I delete the site (created in webDB) from database?

    Hi I have the WebDB 2.2 and Database server Oracle8i and I created a lot of sites with WebDB but I do not know how can I delete them from database server. Could somebody help to me?

    Log into sql plus as webdb
    Drop user <site name>_admin cascade;
    Drop user <site name>_public cascade;
    Drop user <site name> cascade;
    and drop any other users you have made specically for this site.
    Remove the dad from the listener settings.
    If you wish to use this site name again in the same database you also have to delete a record from a table in the Webdb schema.
    I can't remeber what that is.....
    Good Luck
    Dave.
    null

  • How to delete all rows data from database

    Hello All.
    I have a database username 'abc'. This database contain 123 tables & have many data.
    I want to empty all the database. Is it possible that clear all the database with a single query.
    if yes then kindly tell me about the query .
    Thanks
    Diamond

    Keep in mind that you cannot rollback the truncate command.
    Once you truncate a table all of it's data AND statistics are gone.
    If you do not want to use PL/SQL to delete all rows you can generate a script by SQL
    SCOTT@ORCL> SELECT ' TRUNCATE TABLE '|| TABLE_NAME||';' FROM USER_TABLES;
    'TRUNCATETABLE'||TABLE_NAME||';'
    TRUNCATE TABLE BONUS;
    TRUNCATE TABLE SALGRADE;
    TRUNCATE TABLE DEPT_LOV;
    TRUNCATE TABLE TITLE;
    TRUNCATE TABLE TEST_DATE;
    TRUNCATE TABLE DEPT;
    TRUNCATE TABLE REP;
    TRUNCATE TABLE REP_PARAM;
    TRUNCATE TABLE EMP;
    10 rows selected.
    SCOTT@ORCL> SELECT 'DELETE FROM '|| TABLE_NAME||';' FROM USER_TABLES;
    'DELETEFROM'||TABLE_NAME||';'
    DELETE FROM BONUS;
    DELETE FROM SALGRADE;
    DELETE FROM DEPT_LOV;
    DELETE FROM TITLE;
    DELETE FROM TEST_DATE;
    DELETE FROM DEPT;
    DELETE FROM REP;
    DELETE FROM REP_PARAM;
    DELETE FROM EMP;
    10 rows selected.
    SCOTT@ORCL>You can save the output in a .sql file and run it.
    Regards,
    Tony

Maybe you are looking for