List:General Discussion« Previous MessageNext Message »
From:yilmaz Date:November 20 2001 9:11am
Subject:why doesn't prepared statement work?
View as plain text  
Hi all,
i have a strange situation here,
i am trying to execute an sql insert via prepared statements.
though it is a simple insert process, i am having a syntax error message.
Doesn't mysql support this?
can someone please tell me what is wrong with this query?

String query="insert into temp(member ,ename,cname,jname ,sex ,age ,"+
     "nation ,prf ,occ  ,educ ,address ,city ,res_city,res_address ,"+
     "htel ,mtel,otel ,fax ,email) "+
    " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        PreparedStatement stmt=conn.prepareStatement(query);

    stmt.setString(1,member);
    stmt.setString(2,ename);
    stmt.setString(3,cname);
    stmt.setString(4,jname);
    stmt.setString(5,sex);
    stmt.setInt(6,age);
    stmt.setString(7,nation);
    stmt.setString(8,prf);
    stmt.setString(9,occ);
    stmt.setString(10,educ);
    stmt.setString(11,address);
    stmt.setString(12,city);
    stmt.setString(13,res_city);
    stmt.setString(14,res_address);
    stmt.setString(15,htel);
    stmt.setString(16,mtel);
    stmt.setString(17,otel);
    stmt.setString(18,fax);
    stmt.setString(19,email);
   stmt.executeUpdate(query);

  stmt.close();
  conn.close();

the error message says:
javax.servlet.ServletException: Syntax error or access violation: You have
an error in your SQL syntax near '?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)' at
line 1


thanks a lot in advance :)


Thread
why doesn't prepared statement work?yilmaz20 Nov
  • Re: why doesn't prepared statement work?yilmaz20 Nov
  • Re: why doesn't prepared statement work?DL Neil20 Nov
  • Re: why doesn't prepared statement work?yilmaz20 Nov
  • Re: why doesn't prepared statement work?yilmaz20 Nov
    • Re: why doesn't prepared statement work?Dan Nelson20 Nov