I have written a simple program in java, which creates connection to Oracle database and executes update query.
The query gets executed successfully, but if the update query contains a column starting with "F" then prepareStatement.getParameterMetaData()
throws exception
"java.sql.SQLSyntaxErrorException: ORA-00904: "F": invalid identifier".
If I remove the column starting with "F" then prepareStatement.getParameterMetaData()
executes correctly.
My configruation is,
Oracle: 12.1.0.2
JDK: 1.8
ojdbc driver: ojdbc7.jar (included in 12.1.0.2)
I found the same issue with ojdbc6.jar
as well.
Is there any issue with the driver?
Code:
public class TestDriver {
public static void main(String args[]) {
String sql = "UPDATE test SET test1 = ?, Fun=? WHERE test2 = ?";
PreparedStatement ppt = null;
Connection connection = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(
"jdbc:oracle:thin:@127.0.0.1:1521/pdborcl2","oracleTrunk","oracleTrunk");
ppt = connection.prepareStatement(sql);
for(int i=0; i<1;i++) {
ppt.setString(1, null);
ppt.setString(2, null);
ppt.setString(3, "1");
ppt.executeUpdate();
System.out.println("MSG "+ppt.getParameterMetaData());
}
}catch(Exception e) {
System.out.println("e "+e);
} finally {
try {
ppt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}