
-----------------------------------
deltatux
Sat Jun 07, 2008 4:06 pm

Java and SQL: data mismatch
-----------------------------------
Alright, I'm having some really funky issue with this. I know it's a mismatch (obviously) and I want to know if the Compsci community members can help me solve this issue. It's been annoying me a lot of late.


  try{
        libSQL myAddNewData = new libSQL();
        String strRownum =(String.valueOf(jComboBoxLName.getSelectedItem()));
        if (intChoice == 1){
            myAddNewData.AddNewData("INSERT INTO CUSDATA (FIRSTNAME, LASTNAME, PHONE, SIN) VALUES ('"+ strUserData[intCount][0] +"','" + strUserData[intCount][1] + "','"  + strUserData[intCount][5] + "','" + strUserData[intCount][8] + "')");
            myAddNewData.AddNewData("INSERT INTO CUSLOCATION (ADDRESS, CITY, [POSTAL CODE], COUNTRY, PROVINCE) VALUES ('" + strUserData[intCount][2] + "','" + strUserData[intCount][3] + "','" + strUserData[intCount][4] + "','" +strUserData[intCount][6] + "','" + strUserData[intCount][7] + "')");   
        }
        if (intChoice == 2){
            myAddNewData.AddNewData("UPDATE CUSDATA SET FIRSTNAME = '" + jTextFieldFName.getText() + "', PHONE = '" + jTextFieldPh.getText() + "', SIN = '" + jTextFieldSIN.getText() + "' WHERE ID = '" + strRownum + "'");
            myAddNewData.AddNewData("UPDATE CUSLOCATION SET ADDRESS='" +  jTextFieldAddr.getText() + "', CITY = '" + jTextFieldCity.getText() +"', [POSTAL CODE] = '" + jTextFieldPC.getText() + "'  WHERE ID = '" + strRownum + "'");
        }
        if (intChoice == 3){
            myAddNewData.AddNewData("DELETE FROM CUSDATA WHERE ID = '" + strRownum + "'");
            myAddNewData.AddNewData("DELETE CUSLOCATION WHERE ID = '" + strRownum + "'");
        }
    }catch(Exception e){
        jTextArea1.append("SQLException: " + e.getMessage());
    }


The error I get when I initiate the UPDATE command:

init:
deps-jar:
Compiling 1 source file to D:\devel\java\netbeans\Grade 12\SIN\build\classes
compile:
run:
Error: java.sql.SQLException: 

Here's a screenshot of my databases:
http://www.imagefilez.com/out.php/i256771_cuslocdesn.png
http://www.imagefilez.com/out.php/i256770_cusdatadesn.png

Thanks,
deltatux

-----------------------------------
Mayb123
Thu May 21, 2009 12:54 pm

Re: Java and SQL: data mismatch
-----------------------------------
well, i'd say i know by now, but i'm looking for answers too:P it's Mitch, btw

-----------------------------------
DemonWasp
Thu May 21, 2009 1:28 pm

RE:Java and SQL: data mismatch
-----------------------------------
I could be wrong, as this is just from a Google search, but I don't think you're supposed to put single-quotes around numeric values in SQL.

-----------------------------------
Vermette
Thu May 21, 2009 1:56 pm

Re: RE:Java and SQL: data mismatch
-----------------------------------
I could be wrong, as this is just from a Google search, but I don't think you're supposed to put single-quotes around numeric values in SQL.

I know Oracle can handle it without sweating since 8i at least.  Access I don't have a clue.  I google'd too and found this same post elsewhere:  the OP hit quite a few sites with identical code.

Also, this code scares me.
