public abstract class EmployeePictureBean implements EntityBean
{
....
public abstract byte[] getPicture();
public abstract void setPicture(byte[] newPicture);
public Long ejbCreate(Long empno, byte[] newPicture)
{
setEmpno(empno);
setPicture(newPicture);
return empno;
}
public void ejbPostCreate(Long empno, byte[] newPicture)
{
}
...
}
<entity-deployment name="EmployeePicture" data-source="jdbc/OracleDS"
table="EMPPIC">
<PRimkey-mapping>
<cmp-field-mapping name="empno" persistence-name="EMPNO"
persistence-type="NUMBER(8)"/>
</primkey-mapping>
<cmp-field-mapping name="empno" persistence-name="EMPNO"
persistence-type="NUMBER(8)"/>
<cmp-field-mapping name="picture" persistence-name="PICTURE"
persistence-type="BLOB"/>
</entity-deployment>
// Locate and open the file
File imgFile = new File(fileName);
long imgFileSize= imgFile.length();
// initialize the byte array
byte byteValue[] = new byte[(int)imgFileSize];
// Read the file into the byte array
InputStream is = new BufferedInputStream(new FileInputStream(imgFile));
新闻热点
疑难解答