Announcement Announcement Module
Collapse
No announcement yet.
problem with SqlUpdate and the euro symbol '' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with SqlUpdate and the euro symbol ''

    Hi,

    I'm having troubles using org.springframework.jdbc.object.SqlUpdate to insert a String value containing the euro symbol '' in a VARCHAR field in MySQL.
    The query gets executed, but the value saved on the DB has the euro symbol replaced with a question mark '?'.
    For example, the string "abc def" is saved as "abc ? def" on the DB.

    The same query executed with a MySQL client (Navicat 8) saves correctly the euro symbol on the DB.
    I'm using Spring framework version 2.5.


    This is the (simplified) code I'm using:

    Code:
    String query = "insert into myTable (name) values (?)";
    
    KeyHolder keyHolder = null;
    SqlUpdate su = new SqlUpdate();
    su.setDataSource(getDataSource());
    su.setSql(query);
    su.declareParameter(new SqlParameter(Types.VARCHAR));
    su.setReturnGeneratedKeys(true);
    su.compile();
    
    Object[] parameters = new Object[]{name};
    keyHolder = new GeneratedKeyHolder();
    su.update(parameters, keyHolder);
    
    int result = keyHolder.getKey().intValue();
    Any idea why this problem happens? What am I missing?
    Thank you for any help!

  • #2
    I have tested with normal query and working fine.

    Code:
    <property name="address" type="string" column="address"
    			not-null="false" length="20" />
    use this below code for storing euro simple

    Code:
    PreparedStatement stmt = con.prepareStatement(
    				"Insert into Customer (id,name,address) " +
    					" values (102,'Capgemini','')");

    Comment


    • #3
      Thank you for your answer mumbaimuru, unfortunately I have no Connection object available to build the PreparedStatement object with.

      Anyway we managed to solve the problem by updating the connector library... We were using mysql-connector-java-5.1.6-bin.jar, and updating to mysql-connector-java-5.1.10-bin.jar did the trick.

      I hope this can be useful to anyone running into the same problem.

      Comment

      Working...
      X