Missing operator in query expression (Help)
Hi I'm trying to implement "OR" into my SQL statement and I think I'm doing something wrong.. Could someone take a quick look at my query and tell me where I'm missing this operator.
int insert=stmt.executeUpdate("INSERT INTO tblTest(EnglishName, FileName, RlsID, InitRlsInd, DirID, ObsoleteRlsInd) VALUES
("+"\'"+jTextFieldName.getText()+"\'"+","+
"\'"+jTextFieldFileName.getText()+"\'"+","+
"\'"+getComboID(jComboBoxRelease)+"\'"+","+
"\'"+getRadioID(jRadioButtonInitRlsY)+"\'"+","+"OR"+getRadioID (jRadioButtonInitRlsN)+"\'"+","+
"\'"+getComboID(jComboBoxDirectory)+"\'"+","+
"\'"+getRadioID(jRadioButtonObsoRlsY)+"\'"+","+"OR"+getRadioID(jRadioButtonObsoRlsN)+"\'"+ ")");
Thanks in advance.
> awesome! I was wondering if there was an alternative
> method of writing a SQL statement in Java.. all
> those "" and stuff were brutal....
>
> Thanks
Yes. Also PreparedStatements will handle the formatting of data values. That means the proper escaping of quotes within text and db specific date formats. etc.
cotton if your still out there..
String sql = "INSERT INTO tblTest("
+ "EnglishName,"
+ "FileName,"
+ "RlsID,"
+ "InitRlsInd,"
+ "DirID,"
+ "ObsoleteRlsInd,"
+ "VALUES(?,?,?,?,?,?)";
PreparedStatement pstmt = dB.prepareStatement(sql);
Now if I use pstmt and continue my INSERT I am not able to implement the values the users will put into the text and combo boxes..
I tried this for the textbox, but it doesn't work... pstmt.setString(jTextFieldName.getText()); I know this is obviously wrong, but I'm unfirmilar with prepared statments and I looked at the Java Docs and they don't show a specific example for what I want to do.. Atleast what I found doesnt. Could you show me a quick example?
Thanks,