Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java and SQL: data mismatch
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
deltatux




PostPosted: Sat Jun 07, 2008 4:06 pm   Post subject: 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.

code:

  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:
Quote:

init:
deps-jar:
Compiling 1 source file to D:\devel\java\netbeans\Grade 12\SIN\build\classes
compile:
run:
Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
BUILD SUCCESSFUL (total time: 36 seconds)


Here's a screenshot of my databases:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Thanks,
deltatux
Sponsor
Sponsor
Sponsor
sponsor
Mayb123




PostPosted: Thu May 21, 2009 12:54 pm   Post subject: 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




PostPosted: Thu May 21, 2009 1:28 pm   Post subject: 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




PostPosted: Thu May 21, 2009 1:56 pm   Post subject: Re: RE:Java and SQL: data mismatch

DemonWasp @ May 21st 2009, 13:28 wrote:
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.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: