Problems: insert record with Apostrophe by PreparedStatement
Posted by: Genius Tse
Date: March 06, 2005 10:05AM

I m using JSP + JavaBeans to access Mysql with PreparedStatement
when insert a records which contains Apostrophe and the SQLException will be thrown

According exception message, it shows that the SQL statement is added \\ in front of all Apostrophe
input: 123'456'789
error msg in console: 123\\'456\\'789

Does anybody can help me ~~~

and the following is a parts of the source code:
public int insertLinkCat(LinkCat linkcat){
int insertCount=0;
sql="insert into link_catalog(catID, cat_name) values(?,?)";
Connection conn=db.getConnection();
PreparedStatement pstm=conn.prepareStatement(sql);
int i=1;



catch(SQLException sql){
return insertCount;

Options: ReplyQuote

Written By
Problems: insert record with Apostrophe by PreparedStatement
March 06, 2005 10:05AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.