को iTextPDF दस्तावेज़ कन्वर्ट करने के लिए मैं बाइट [] को iTextPDF दस्तावेज़ फ़ाइल को रूपांतरित करने के बाद यह स्मृति में बनने वाले की जरूरत है। मैंने पहले से ही परीक्षण किया है कि मुझे पीडीएफ बनाने के साथ कोई समस्या नहीं है। समस्या यह है कि इसे डीबी में स्टोर करने के लिए बाइट सरणी में कैसे परिवर्तित करें।कैसे बाइट सरणी
Document generatedDocument = reportService.generateRequestForm(scdUser, jsonObject, 0, null);
reportService.generateRequestForm(scdUser, jsonObject, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter pdfWriter = PdfWriter.getInstance(generatedDocument, baos);
generatedDocument.open();
document.setDocument(baos.toByteArray()); // stores as blob
मैं डेटाबेस ब्लॉब स्तंभ पर अशक्त का मूल्य मिला:
यहाँ मेरी कोड है।
यहाँ मेरी दस्तावेज़ डोमेन वस्तु है:
दस्तावेज़ डोमेन वस्तु
@Entity
@Table(name = "document")
public class Document implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "document_id", nullable = false)
private int documentId;
@Column(name = "document_name", nullable = false, length = 65535)
private String documentName;
@Column(name = "document_type", nullable = false)
private int documentType;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "upload_date", nullable = false, length = 19)
private Date uploadDate = new Date();
@Column(name = "document", nullable = false)
private byte[] document; // BLOB COLUMN
@Column(name = "document_size", nullable = false)
private long documentSize;
@Column(name = "title", nullable = true, insertable = true, updatable = true, length = 65535, precision = 0)
private String title;
@Column(name = "tag", nullable = true, insertable = true, updatable = true, length = 65535, precision = 0)
private String tag;
@Column(name = "description", nullable = true, insertable = true, updatable = true, length = 65535, precision = 0)
private String description;
@Column(name = "shared", nullable = false, insertable = true, updatable = true, length = 1, precision = 0)
private boolean shared = false;
@Column(name = "status", nullable = false)
private int status = DocumentStatus.READY.getStatus();
public int getDocumentId() {
return this.documentId;
}
public void setDocumentId(int documentId) {
this.documentId = documentId;
}
public String getDocumentName() {
return this.documentName;
}
public void setDocumentName(String documentName) {
this.documentName = documentName;
}
public int getDocumentType() {
return this.documentType;
}
public void setDocumentType(int documentType) {
this.documentType = documentType;
}
public Date getUploadDate() {
return this.uploadDate;
}
public void setUploadDate(Date uploadDate) {
this.uploadDate = uploadDate;
}
public byte[] getDocument() {
return this.document;
}
public void setDocument(byte[] document) {
this.document = document;
}
public long getDocumentSize() {
return this.documentSize;
}
public void setDocumentSize(long documentSize) {
this.documentSize = documentSize;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean getShared() {
return shared;
}
public void setShared(boolean shared) {
this.shared = shared;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
प्रश्न को देखें, फिर अपनी अंतिम वाक्य देखें .. – Eugene
ऐसा लगता है कि दस्तावेज़ उस डेटाबेस त्रुटि के कारण पहली बार उत्पन्न नहीं होगा। –
@ यूजीन यह वही है; मैं कॉलम blob करने के लिए बाइट [] बना रहा हूँ। – talha06