oracle12c - getParameterMetaData() throws java.sql.SQLSyntaxErrorException: ORA-00904: "F": invalid identifier -


i have written simple program in java, creates connection oracle database , executes update query.

the query gets executed successfully, if update query contains column starting "f" preparestatement.getparametermetadata() throws exception

"java.sql.sqlsyntaxerrorexception: ora-00904: "f": invalid identifier".

if remove column starting "f" 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 same issue ojdbc6.jar well.

is there issue driver?

code:

public class testdriver {

public static void main(string args[]) {     string sql = "update test set test1 = ?, fun=? 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);     } {         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();         }     }  } 

this sounds bug me, since preparedstatement works expected. however, found workaround:

if use quotes define columns, ppt.getparametermetadata() not throw exception more.

so need write

string sql = "update test set test1 = ?, \"fun\"=? test2 = ?"; 

keep in mind when using double quotes define names in oracle have case sensitive. \"fun\" , not \"fun\" because names converted uppercase when used without quotes.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -