Why can't I use rs.deleteRow() method to delete a record?

the code as such�F
<%
String sql="select id,name from test";
ResultSet rs = jconst.executeQuery(sql);
rs.next();
out.print(rs.getInt("id"));
try
rs.deleteRow();
catch (SQLException e)
out.print("can't delete record");
return;
out.print("success");
%>
the result is "can't delete record" ,why? I use mysql database�C"jconst" is the bean of connect to mysql database! In the "jconst" bean , I use such method to return Resultset :
public ResultSet executeQuery(String sql)
rs = null;
try
conn = DriverManager.getConnection(ConnStr);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
catch(SQLException ex)
System.err.println("aq.executeQuery: " + ex.getMessage());
return rs;

It's again the problem with not commiting the changes to databse. In order to commit changes to the database, you need to call the commit() of Connection explicitly or simply close the Statement and Connection objects in your bean.
After rs.deleteRow() in your jsp you call another method of your bean jconst.saveChanges(); and add this method in your bean.
public void saveChanges() {
try {
stmt.close();
conn.close()
} catch(SQLException sqle) {
//handle the exception
I hope this will work.
Sudha
PS: It's not a good practice to manipulate the database from your JSP. JSP is meant for presentation. You can do all these operations from bean itself.

Similar Messages

  • Why can I not use mouse or keyboard to delete text?

    I have encountered a strange anomaly.  I have recently installed the update to OSX and iTunes, and now I have been unable to delete text or correct mistakes using the DELETE key on keyboard or the mouse itself.  I can only delete with the pull down menues in Safari or Entourage (my email preference).  Any ideas?

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your documents or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • I used an American Express card to purchase my Ipad from Apple online. I have an Apple ID. why can't I use Amex as my payment method when signing in to Itunes?

    I have an Apple ID, created when I recently purchased an ipad from Apple online. I used my Amex as payment method. Why can I not use my Amex as payment method when signing in to iTunes for the first time?

    Yup, I'm a Kiwi, living in sunny Blenheim. Just seems odd that I can use Amex for purchasing in the Apple store but not in the iTunes store. Perhaps the higher charge set by Amex is not  economic for small purchases? Anyway,
    I know now what to do now - buy an iTunes gift card and enter the activation code to redeem and sign up. Sorted! Thanks Kappy for taking an interest in my query.

  • Why can't i use my visa on my iphone ?

    why can't i use my visa card?

    I dont know?  what happens when you try?  visa is an acceptable payment method.

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • Why can't I use Paypal to purchase application in Portugal

    Why can't I use Paypal to purchase application in Portugal?

    Apple isn't here. Apple doesn't answer questions. here.
    PayPal isn't offered as a payment method for Portugal. No one here can tell you more than that or why.

  • Why can't I use my itune card I redeemed

    Why can't I use a gift card I recieved to make itune purchases

    What happens when you try to buy something, what are you trying to buy (you can't use your balance for gifting, you can only use a credit card) ?
    If this is the first time that you've tried to buy something and you are being prompted to enter card details then unless you used the instructions on this page when creating it : Create an iTunes Store, App Store, or iBooks Store account without a credit card or other payment method
    then credit card details will need to be entered before the account can be used to download any item from the store. You should be able to remove the card after entering it.
    Or, and if you are being prompted to review the account, then you could see if this post by mountaingoatgirl lets you do so without needing to enter credit card details : https://discussions.apple.com/message/24303054#24303054
    If you are getting a message to contact iTunes Support then to do so (these are user-to-user forums) :
    - go to http://www.apple.com/support/itunes/ww
    - click on your country's flag
    - click on the Contact Support at the bottom of the left-hand column
    - click on Contact iTunes Store Support on the right-hand side of the page
    - then Purchases, Billing & Redemption
    If it's a different problem ... ?

  • Hi, my MacBook Air is not working anymore if it's not connected with the power cable. It's pretty new so I can't imagine that the battery is dead already. Why can't I use my MacBook Air without the power cable even though I charged it for hours?

    Hi, my MacBook Air is not working anymore if it's not connected with the power cable. It's pretty new so I can't imagine that the battery is dead already. Why can't I use my MacBook Air without the power cable even though I charged it for hours?

    Please take the Mac to  Apple store to have it checked out.
    Genius Bar reservation
    http://www.apple.com/retail/geniusbar/
    Best.

  • Why can't I use my mid 2010 macbook pro with 8GB memoir and NVIDIA GEForce GT 330M 256MB to run 3D in photoshop CC?

    Why can't I use my mid 2010 macbook pro with 8GB memoir and NVIDIA GEForce GT 330M 256MB to run 3D in photoshop CC?

    3-D is very memory intensive.
    System requirements | Photoshop
    Mac OS
    Multicore Intel processor with 64-bit support
    Mac OS X v10.7, v10.8, or v10.9
    2 GB of RAM (8 GB recommended)
    3.2 GB of available hard-disk space for installation; additional free space required during installation (cannot install on a volume that uses a case-sensitive file system or on removable flash storage devices)
    1024x768 display (1280x800 recommended) with 16-bit color and 512 MB of VRAM (1 GB recommended)**
    OpenGL 2.0–capable system
    Internet connection and registration are necessary for required software activation, membership validation, and access to online services.*
    ** 3D features are disabled and some Mercury Graphics Engine enhanced features may not work with less than 512 MB VRAM. Read the Help article.
    Bottom line, you don't have enough VRAM
    Nancy O.

  • Why can't we use iTunes gift cards with family sharing? After Christmas, we now have lots of account credit we can't use. Very frustrating.

    Why can't we use iTunes gift cards with family sharing? After Christmas, we now have lots of account credit we can't use. Very frustrating. There is no option found for using account credit.

    I just logged out of my daughter's account and back in, and now it works. Deducted from gift card account balance. So I hope this is resolved.

  • HT4061 Why can't I use face time on 3G internet

    Why can't I use FaceTime on 3G internt

    This feature will only be available when the new update ios6 comes out in sept or october and will only be for the iphone 4s or the new ipad if havent got one of these devices then facetime will only work over wifi the reason apparently the older devices are unable to handle it requires more processing power.

  • Hi, why can't I use the iMessage on my iPhone? I've already had my apple id email on it but it keeps saying "waiting for activation" always like that. No progress. Could anybody help me on this? Cheers

    Hi, why can't I use the iMessage on my iPhone? I've already had my apple id email on it but it keeps saying "waiting for activation" always like that. No progress. Could anybody help me on this? Cheers

    I have an old iPod Touch with old software that can no longer be updated:
    iOS version 6.1.6
    I've been searching for a solution to my iMessage login problem for months and tried everything from those frustrating links and all the tips from other users.
    Here is what finally worked:
    1) Settings > Privacy > Location Services > On
    2) Settings > General > Date & Time > Set Automatically > On
    3) Reboot device until Apple logo appears
    4) Settings > Messages > Sign In

  • Why can't I use Emoji keyboard on my IOS7?, Why can't I use Emoji keyboard on my IOS7?, Why can't I use Emoji keyboard on my IOS7?

    Why can't I use the Emoji keyboard on my IPad Air?

    u need to set up 1st the Emoji keyboard. How ?
    setting>keyboard>keyboards>Add new keyboard>select Emoji

  • Why can't i use credit card on app store its money on it and its an visa card

    why can't i use credit card on app store its money on it and its an visa card

    Credit cards do need to be from the same country as your account, which may or may not apple, but if you're visiting from another country and trying to use, for example, a UK card in the US app store, it won't work.
    Could you have typo'd a number? Or could the card be expired?
    http://support.apple.com/kb/HT5552
    has more info on what's accepted.
    Is this a visa gift card? I seem to recall people having issues with credit card gift cards.

  • Why can't I use a backslash on my Iphone when entering my email address

    Why can't I use a backslash on my Iphone when entering my email address

    Best thing to do is go to your email, hit reply on any email and find the backslash on your keyboard.  Select the Backslash and then cut/copy it into your mail settings or wherever you want to use it.

Maybe you are looking for