Database don't delete prom the table, help please !!

there is my code :
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con=DriverManager.getConnection(jdbc:odbc:Medic);
con.setReadOnly(false);
try{
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int res=st.executeUpdate("DELETE FROM PATIENT WHERE PATIEN_ID="+id+";");
System.out.println(String.valueOf(res)+" rows deleted");
st.close();
}catch(Exception exc){
System.out.print(exc+"\n");
the code execute with no error or exception , the message that i recieve is "1 rows deleted" and i want delete just one row, it's ok until the moment but whene i read the table i see that the row is not deleted.
I use dBase database, help please !!!
Thanks

Don't trust the return value.
Because you got no exception it means that the SQL executed. SQL can execute without deleting anything however if the where clause does not match.
As posted your code is not valid java so anything else is meaningless.

Similar Messages

  • I can't insert my data into the table - help please

    Hello everyone,
    I have a trouble about JSP. I'm using Java2 SDK,JSP 1.2,Mysql and TOMCAT.
    I want to do this. A user has to enter the nicno,into the html form(EnterNicInter.jsp),to verify if it is already exist or not. If it is exist in the db, an error msg(Record already exist) must be displayed. If not, then the page "InterviewForm.jsp" displayed. This part is working.
    But, I can't save these details into the db by clicking submit button int the InterviewForm.jsp.
    I wrote a javaBean for this task. Here is it.
    CandidateMgr.java
    package hrm;
    import java.io.*;
    import java.sql.*;
    public class CandidateMgr
         private String nicno;
            private String title;
            private String firstName;
         private String civilStatus;
            private String tele;
            private String eduQua;
         // Constructor
         public CandidateMgr()
              this.nicno = nicno;
              this.title = title;
              this.firstName = firstName;
              this.civilStatus= civilStatus;
              this.tele = tele;
              this.eduQua = eduQua;
              //getters & setters.
               // Initializes the connection and statements
            public void initConnection() {
                    if (connection == null) {
                 try {
                          String sql;
                          // Open the database
                          Class.forName(DRIVER).newInstance();
                          connection = DriverManager.getConnection(URL);
                          //Verify nicno
                          sql="SELECT * FROM Candidate where nicNo= ?";          
                   pstmt1 = connection.prepareStatement(sql);
                   sql ="INSERT INTO Candidate                               
                   VALUES(?,?,?,?,?,?)";
                   pstmt2 = connection.prepareStatement(sql);
             catch (Exception ex) {
                System.err.println(ex.getMessage());
         public boolean verifyNicNo(){
              boolean nic_no_select_ok = false;
              String nic="xxxx";
              initConnection();
                    try {
                       pstmt1.setString(1, nicno);
                   ResultSet rs1 = pstmt1.executeQuery();               
                                if(rs1.next()){
                        nic=rs1.getString("nicNo");
                               if(nic=="xxxx")
                        nic_no_select_ok = true;
                   } else{
                        nic_no_select_ok = false;     
                   rs1.close();
                           pstmt1.close();
                    catch (Exception ex) {
                      System.err.println(ex.getMessage());
              return nic_no_select_ok;
         public boolean addInter(){
              boolean add_inter_ok = false;
              try{
                      //assign values for the object
                   pstmt2.setString(1, nicno);   //      ERROR(java:652)
                   pstmt2.setString(2, title);
                   pstmt2.setString(3, firstName);
                   pstmt2.setString(4, civilStatus);
                   pstmt2.setString(5, tele);     
                   pstmt2.setString(6, eduQua);
                   if(pstmt2.executeUpdate()==1) add_inter_ok=true;
                   pstmt2.close();  
                  catch(SQLException e2){
                           System.err.println(e2.getMessage());
              return add_inter_ok;
    IntreviewForm.jsp (used to submit data into the db)
    <form method="POST" action="InterviewCtrl.jsp">
         //codes
    <input type="text" name="nicno" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    <input type="text" name="title" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    <input type="text" name="firstName" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    <input type="text" name="civilStatus" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    <input type="text" name="tele" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    <input type="text" name="eduQua" size="14" style="border:1px solid #0000FF;           
    color: #FF0000; font-weight: bold">
    </form>.......................................................................
    Here is the "InterviewCtrl.jsp"
    <%@ page language="java" import="java.util.*"%>
    <%@ page import="hrm.CandidateMgr" %>
    <%@ page session="false" %>
    <jsp:useBean id="candidate" class="hrm.CandidateMgr" scope="request"/>
    <jsp:setProperty name="candidate" property="*"/>
    <%-- Execute the addInter() method on the bean and check if it is true or false.-- %>
    <%-- if it's true then display a confirmation message "InterConfirm.html" --%>
    <%-- else display InterError.html --%>
    <%
    String nextPage ="MainForm.jsp";
    if(candidate.addInter()){
         nextPage="InterConfirm.html";
         }else{
         nextPage="InterError.html";
    %>
    <jsp:forward page="<%=nextPage%>"/>.......................................................................
    Here is the error:(I mark it in my bean also)
    root cause
    java.lang.NullPointerException
         at hrm.CandidateMgr.addInter(CandidateMgr.java:652)
         at org.apache.jsp.InterviewCtrl_jsp._jspService(InterviewCtrl_jsp.java:66)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    I use JSP 1.2 , mySQL with TOMCAT. My table name is Candidate.It's fields are as follows:
    Candidate(nicNo,title,fName,civilStatus,tele,eduQua)
    Can anybody tell me whats going on, help me to solve this please.
    Thanks.

    you should try something different, since you are mixing up a lot of code.
    1) create a separate method just to connect and disconnect from a database;
    2) use the value entered and see if you can find a record in the table. If the record is there, then you should re-direct your jsp to a jspError, else goes to another form.
    the code below give you some idea
          if( sAction.equals("Add1") ) {
            sITEM = request.getParameter("parameter1");
            try {
              itemmaster.connect();
              itemmaster.viewitemmaster( sITEM );
              rs = itemmaster.getRs();
              if( rs.next() ) {
                sURL = "additemmaster1.jsp";
              else {
                request.setAttribute( "asITEM", sITEM );
                sURL = "additemmaster2.jsp";
            finally {
              rs.close();
              itemmaster.disconnect();
          }

  • Records have been deleted from the table.

    Hi all ,
    If records have been deleted from the table that any log file maintains the history as following Way.
    User Name who delete the records.
    Machine name where the command is execute.
    The command syntax e.g delete from abc where ……..
    or any other help related to mentioned problem.
    Regards,
    Mobeen.

    Wrong forum .. your question doesnt make much sense.
    But take a look at Oracle Auditing.

  • I download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    i download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    Well you can sync your iPod/iPhone to yur computer or laptop then take the photos off of your iPod like taking photos of of a SD card (from a normal camera) or off of a USB..! Good Luck. plz tick this saying This solved my question if it helps you.

  • Request in steps in deleting all the tables data in an user schema.

    Hi Gurus,
    Could some one please provide me the steps involved in deleting all the tables data in an user(schema)
    thanks in advance

    write a script as below
    sys@11GDEMO> select 'truncate table '||owner||'.'||table_name||';' from dba_tables where owner='SCOTT';
    'TRUNCATETABLE'||OWNER||'.'||TABLE_NAME||';'
    truncate table SCOTT.DEPT;
    truncate table SCOTT.EMP;
    truncate table SCOTT.BONUS;
    truncate table SCOTT.SALGRADE;
    truncate table SCOTT.EMPBACKUP;
    truncate table SCOTT.T_NAME;
    truncate table SCOTT.D_TEMP_STSC;
    Example:
    sys@11GDEMO> truncate table SCOTT.T_NAME;
    Table truncated.
    sys@11GDEMO>

  • Data gets deleted for the table RSTRFIELDSH

    If data gets deleted for the table RSTRFIELDSH at BW end
    ...what should i do?to get it back

    Wim,
    We lost the data from production. We ran Archive program to archive the data and archiving file is still exist.
    There is no possibliity to run the OUTBOUND process again to create the IDOCs.
    But only my concern is When we run the Transaction SARA we will be getting the data for other period as well.
    But I need to reload the data for three months only because that archiving file also has other period data as well.
    Can you send me details of how to use SARA Transaciton for particular period.
    Thanks,
    Kalikonda.

  • Hello i can't finish my review on my phone because i don't have a bank card so i don't what to do any help please?

    hello i can't finish my review on my phone because i don't have a bank card so i don't what to do any help please?

    Disabled
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • I'm in syria and they blocked me from using any VPN service please help without VPN i can't open the store help please ( using iphone 5 version 9.1.4 )

    I'm in syria and they blocked me from using any VPN service please help without VPN i can't open the store help please ( using iphone 5 version 9.1.4 )

    There is nothing that anyone here on a user forum can do to help you.  If it is a local issue in Syria, then you need to take it up with your phone company or authorities there who have prevented you from using VPN.
    Nobody here can help you.

  • HT204406 I have a lenovo tablet running windows 8 - only 4 of my albums are showing in my list - this is my 4th device and I subscribe to the cloud HELP  please I want to see my music

    have a lenovo tablet running windows 8 - only 4 of my albums are showing in my list - this is my 4th device and I subscribe to the cloud HELP  please I want to see my music

    See the futher information area of Troubleshooting issues with iTunes for Windows updates for download advice and direct links if required.
    See this migrate iTunes library post for advice on moving the library over from a previous computer and this post on deduplication.
    tt2

  • How to get images dynamically from database without file paths in the table field

    I have a MS-Access database. I am working with ASP.NET. In the database there is product table in which I have "CodeNo" as a field which is a text field, and the product codes like "SM-R-2035". I also have another field "Image" which is also a text field and which have a file path in it corresponding to the particular product Image (e.g. Images\Products\SM-R-2035.jpg). So far every thing is ok. I have to update this site very frequently and lots of images are added each and every time. Its a tedious work to type the paths and file name every time and it also take a lot of time.
    What I am asking is : Is it possible to get images from a specific folder at runtime which is referenced by the "code no" itself and not the file path from the database. (Say at run time the "code no" is referenced from the database and the corresponding image is loaded dynamically from the specified folder). In other word I want to avoid the tedious work of typing.
    Can any one help with this issue. Any other simple suggestions are welcome.

    All you need to do is simple concatenation to obtain the path for the image file.  You didn't mention whether you are using VB.Net, C# or some other language to do your coding.
    If the code in your database is SM-R-2035, the file name is SM-R-2035.jpg and the path to the images foilder is Images\Products\SM-R-2035.jpg, Conceptually here is what you need to do:
    dim code_var
    dim path_var
    code_var = the code you obtain from your relevant field in the database
    path_var = "Images\Products\" & code_var & ".jpg"
    Now path_var is what you would call to obtain the image from your images folder.

  • Will table delete remove the table maintenance screens also ??

    hi,
    i created a table. also generated the table maintanence for that. Now if i delete that table will the table maintenance objects also deleted with that ?
    if not then how do i delete them ?
    thks

    Yes, system will ask you if you want to delete it as well.
    Thomas

  • Error in sending mail 2nd time, Where is the fault- Help Please

    Hi friends,
    I had written a program to send mail. Everything is fine, when i send first time. But if I try to send mail 2nd time, It gives the error:
    Exception in Connect: IOException while sending message
    Here is the complete code what i had written, It successfully connects using t.connect();
    the problem in t.send();
    output on JBoss Console is :
    Inside Action
    After Transport t = session.getTransport(protocol)
    before t.connect()
    after t.connect()
    Exception in Connect IOException while sending message
    import java.io.*;
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    public class MsgSend extends Action {
         @Override
         public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request
                   , HttpServletResponse response) throws Exception {
              response.setContentType("text/xml");
              PrintWriter out = response.getWriter();
              System.out.println("Inside Action");
                String to = request.getParameter("to");
             String bcc = request.getParameter("bcc");
             String cc = request.getParameter("cc");
             String subject = request.getParameter("sub");
             String user = request.getParameter("user");
             //String password = request.getParameter("pass");
             String message = request.getParameter("message");
             String from = user + "@domainname.com" ;
             /*Properties props = System.getProperties();
             props.put("mail.smtp.host", "smtp.vsginc.com");
              MailBean  bean = MailBean.getInstance();          
              Session session = bean.getSession();          
              String protocol = "smtp";
              Transport t = session.getTransport(protocol);
              System.out.println("After Transport t =              session.getTransport(protocol)");
             MimeMessage msg = new MimeMessage(session);
             msg.setFrom(new InternetAddress(from));
             InternetAddress[] address = {new InternetAddress(to)};
             msg.setRecipients(Message.RecipientType.TO, address);
             if(cc != null ){
                   InternetAddress ccAddr[]  = InternetAddress.parse(cc);
                   msg.setRecipients(Message.RecipientType.CC, ccAddr);
              if(bcc != null){
                   InternetAddress bccAddr[] = InternetAddress.parse(bcc);
                   msg.setRecipients(Message.RecipientType.BCC,bccAddr);
             msg.setSubject(subject);
             // create and fill the first message part
             MimeBodyPart messageBodyPart = new MimeBodyPart();
             messageBodyPart.setText(message);
             Multipart multipart = new MimeMultipart();
             multipart.addBodyPart(messageBodyPart);
             Attachment attachment = Attachment.getInstance();
             ArrayList<String> fileList = attachment.getFileNames();
             String parentFolder = null;
             for(String path:fileList){
                  File attachmentFile = new File(path);
                  messageBodyPart = new MimeBodyPart();
                  DataSource source = new FileDataSource(attachmentFile);
                  messageBodyPart.setDataHandler(new DataHandler(source));
                  messageBodyPart.setFileName(attachmentFile.getName());
                  multipart.addBodyPart(messageBodyPart);
                  parentFolder = attachmentFile.getParent();
             // add the Multipart to the message
             msg.setContent(multipart);
             // set the Date: header
             msg.setSentDate(new Date());        
             try {
                  System.out.println("before t.connect()");
                   t.connect(bean.getSmtpServer(),bean.getUsername() ,bean.getPassword());
                   System.out.println("after t.connect()");
                   //Error is coming here in this Line.
                   t.sendMessage(msg, msg.getAllRecipients());
                   * System.gc(); will relese the fileHandles, if some resource
                   * still holds it.               
                   System.out.println("before System.gc()");
                   System.gc();
                   * Deleting All the Files from Attachment Folders.
                  System.out.println("before attachmentFolder");
                  File attachmentFolder = new File(parentFolder);
                  System.out.println("Attachment Folder Name is : "+attachmentFolder.getAbsolutePath());
                  if(attachmentFolder.isDirectory()){
                       File[] files = attachmentFolder.listFiles();
                       System.out.println("No of Files For Attachments are: "+files.length);
                       boolean deleteResult = false;
                       for(int i=0; i<files.length; i++ ){
                            deleteResult = files.delete();
                        System.out.println(files[i].getName() + " Delete Staus is :"+ deleteResult);
              System.out.println("All attachments Deleted");
              out.print("<result>Mail has been sent successfully</result>");
              } catch (Exception e) {
                   out.print("<result>Mail sending failed</result>");
                   System.out.println("Exception in Connect "+e.getMessage());
              }finally{
                   t.close();               
              return null;
    Problem only comes, when i send 2nd time or more. What is the problem? Please help me out.
    Thanks for your response in advance. One more thing, Whether to send a mail & receive a mail, we need to create different sessions. one for sending & one for receiving mails.
    Message was edited by:
    Ashish.Mishra16

    I don't see anything obviously wrong in your code. Try adding
    session.setDebug(true);
    You can use the same Session for sending and for reading.
    A Session just encapsulates your configuration parameters,
    so as long as they're the same for both usages, one Session
    is fine.

  • Cannot open itunes now I've downloaded the update - help please

    I launched my itunes and had a message asking did I want to install the updated version. When it finished installing it said it needed to shutdown and restart - which I did. When I tried to reopen itunes from the shortcut it said it cannot open it coz some files are missing. Can anyone help please. I have contacted apple and although i've had my phone for over 90 days they have emailed me steps on how to uninstalled and reinstall safely. However, once I got the email, the first thing it tells me to do is to launch itunes which I can't do. can anyone help please? Many thanks.

    Hi,
    Try the following
    First of all, see if you can uninstall your current version of HP Support Assistant by using the Microsoft 'Fixit' on the following link - this is particularly useful in correcting issues that may prevent reinstallation on machines running a 64bit OS.
    http://support.microsoft.com/mats/Program_Install_and_Uninstall
    If this completes, restart the PC.
    Next download and install the latest version of HP Support Assistant from the page on the link below - the download links are towards the bottom of the page.
    http://h18021.www1.hp.com/helpandsupport/hp-support-assistant.html
    After the installation, restart the PC again.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • I cant set up my brand new apple iphone 4s as it wont connect to the internet help please

    I cant set up my brand new apple iphone 4s as it wont connect to the internet help please

    Hey vanessafromsouth perth,
    Thanks for using Apple Support Communities.
    It sounds like you are not able to connect to the internet. These articles should be able to help you get connected.
    iPhone: Troubleshooting a cellular data connection
    http://support.apple.com/kb/ts3780
    iOS: Troubleshooting Wi-Fi networks and connections
    http://support.apple.com/kb/TS1398
    Have a nice day,
    Mario

  • I can not play the songs on my iphone 4s, the more they have been transferred to the cell, help please

    I can not play the songs on my iphone 4s, the more they have been transferred to the cell, help please

    Connect your iPod to your computer. When you get the message that it is linked to a different library and asking if you want to link to this one and replace all your songs etc, press "Cancel". Pressing "Erase and Sync" will irretrievably remove all the songs from your iPod. When your iPod appears in iTunes enable it for disk use, this is required for most if not all the utilities listed below so they can access the files: Using your iPod as a storage drive
    The transfer of non iTMS content such as songs imported from CD is designed by default to be one way from iTunes to iPod. However there are a number of third party utilities that you can use to retrieve the music files and playlists from your iPod. This is just a selection, have a look at the web pages and documentation, they are generally quite straightforward, just check for one that soecifically state they work with the iPod shufle. You can also read reviews of some of them here: Wired News - Rescue Your Stranded Tunes
    YamiPod Mac and Windows Versions
    iGadget Windows Only
    iPod Access Mac and Windows Versions
    Music Rescue Mac & Windows
    iPodCopy Mac and Windows Versions
    TuneJack Windows Only
    iPod2PC Windows Only
    There is also manual method of accessing the iPod's hard drive and copying songs back to iTunes on Windows. The procedure is a bit involved and was written long before iTunes 7 and Windows Vista so it requires a little adaptation as the iPod preferences are no longer in the location mention for instance but if you're interested it's posted in this thread: MacMuse - iPod to iTunes

Maybe you are looking for