Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload using html:file tag

 
Dhaval Shah
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm working with struts and hibernate ,i'm getting an error of type mismatch with form bean.
The Form beam has a property as datatype FormFile and my DO has the property of BLOB . i have converted the FormFile into Blob while setting into DO

FormFile ff = stepForm.getInputExampleLocation();
stepDO.setInputExampleLocation(Hibernate.createBlob (ff.getInputStream()));

In JSP:<html:file property="inputExampleLocation" />

now when i want to save in database it give error "Cannot invoke com.alas.docport.web.interview.step.StepForm.setInputExampleLocation - argument type mismatch"...

any idea what can be the problem .

Thank you,
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you tried:

stepDO.setInputExampleLocation(Hibernate.createBlob (ff.getInputStream()));

but you got:

setInputExampleLocation - argument type mismatch

Right?
 
Dhaval Shah
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.alas.docport.common.data.StepDO]; uncategorized SQLException for SQL [insert into DP_STEP (STATUS, NAME, START_TIME, END_TIME, OWNER_ID, STEP_DURATION, PRODUCT_TYPE, STEP_DESCRIPTION, COMPLEXITY, CONTROL_RISK_TYPE, CONTROL_RISK_LEVEL, ACTOR_SENDER_TYPE, ACTOR_SENDER, INP_DATA_TRANSFER_NAME, INP_DATA_TRANSFER_LOCATION, INP_TRANSFER_LOCATION_TYPE, INP_DATA_FORMAT_TYPE, INP_EXAMPLE_LOCATION, ACTOR_RECEIVER_TYPE, ACTOR_RECEIVER, OP_DATA_TRANSFER_NAME, OP_DATA_TRANSFER_LOCATION, OP_TRANSFER_LOCATION_TYPE, OP_DATA_FORMAT_TYPE, OP_EXAMPLE_LOCATION, BIND_ID, VERSION, CREATED_BY, CREATED_DATE, DELETE_STATUS, LAST_UPDATED_BY, LAST_UPDATED_DATE, STEP_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [null]; error code [17090]; operation not allowed: streams type cannot be used in batching; nested exception is java.sql.SQLException: operation not allowed: streams type cannot be used in batching


This is the error i'm getting while saving into database. is there some way we can convert the FormFile into Blob ..or some other way to upload the file

Thank you for replying .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic