0

I tried to store SQL Object into MYSQL table using JDBI. In given POJO object, there is one member(allowed_iam_roles) of type - List<String>. And, it is failing here, by showing exception -

java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'allowed_iam_roles' at row 1

Java code-

@SqlUpdate("insert into bss_interaction_request(username, password, allowed_iam_roles, request_type, " +
            "created_at, completed_at) values(:request.username, :request.password, " +
            ":request.allowedIAMRoles, :request.requestType, :request" +
            ".createdAt, " +
            ":request.completedAt" +
            " );")
    public void storeStoreCredentialsRequest( @BindBean("request") StoreCredentialsRequest storeCredentialsRequest);

Detailed Exception -

INFO  [2017-03-06 05:36:15,899] com.xxx.dataplatform.snowflake.warehousemanagementservice.resources.BSSInteractionResource: Processing request - **StoreCredentialsRequest{requestType=STORE_CREDENTIALS, createdAt=Mon Mar 06 11:06:15 IST 2017, completedAt=null, username='preeti', password='preeti_password', allowedIAMRoles=[codedeploy-gargantua]}**
ERROR [2017-03-06 05:36:16,598] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: dea2d5afb8a3185c
! java.sql.SQLException: **Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'allowed_iam_roles' at row 1**
! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1193) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1328) ~[warehouse-management-service-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! ... 64 common frames omitted
! Causing: org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'allowed_iam_roles' at row 1 [statement:"insert into bss_interaction_request(username, password, allowed_iam_roles, request_type, created_at, completed_at) values(:request.username, :request.password, :request.allowedIAMRoles, :request.requestType, :request.createdAt, :request.completedAt );", located:"insert into bss_interaction_request(username, password, allowed_iam_roles, request_type, created_at, completed_at) values(:request.username, :request.password, :request.allowedIAMRoles, :request.requestType, :request.createdAt, :request.completedAt );", rewritten:"/* BSSInteractionDao.storeStoreCredentialsRequest */ insert into bss_interaction_request(username, password, allowed_iam_roles, request_type, created_at, completed_at) values(?, ?, ?, ?, ?, ? );", arguments:{ positional:{}, named:{request.username:'preeti',request.allowedIAMRoles:[codedeploy-gargantua],request.createdAt:Mon Mar 06 11:06:15 IST 2017,request.password:'preeti_password',request.class:class com.xxx.dataplatform.snowflake.warehousemanagementservice.model.StoreCredentialsRequest,request.completedAt:null,request.requestType:STORE_CREDENTIALS}, finder:[]}]
devsda
  • 4,112
  • 9
  • 50
  • 87
  • Is this question helpful? http://stackoverflow.com/questions/13653712/java-sql-sqlexception-incorrect-string-value-xf0-x9f-x91-xbd-xf0-x9f – zloster Mar 21 '17 at 17:34
  • btw, you can get rid of "request" string in @BindBean annotation and sql body. I.e. refer "username" instead of "request.username" and so on in SQL and (@BindBean StoreCredentialsRequest storeCredentialsRequest) in method arguments section, unless you need to bind multiple beans. – Slava Medvediev Sep 08 '17 at 09:31

0 Answers0