Gemme og hente dok. i database (Igen, igen arne_v )
Hej,Jeg har prøvet at gøre som arne_v foreslog, men det virker ikke.
Min kode:
private byte[] getDok(String id, String name) {
byte[] res = "Nothing Found".getBytes();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
java.sql.Connection connection = null;
java.sql.Statement statement = null;
connection = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@bifrost:1563:DEPM1", user, pw);
statement = connection.createStatement();
java.sql.ResultSet result = null;
java.sql.Blob blob;
String cmd = "SELECT * FROM "+attTabel;
//String cmd = "SELECT * FROM "+attTabel+" WHERE AFTALEID='"+id+"' AND ATT_FIL='"+name+"'";
result = statement.executeQuery(cmd);
if(result.next()) {
contentType = result.getString("CONTENT_TYPE");
blob = result.getBlob("FIL_BLOB");
byte[] blob_res = blob.getBytes((long)1,(int)blob.length());
return blob_res;
}
} catch (Exception e) {
res = ("EXCEPTION"+e).getBytes();
}
return res;
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletOutputStream out = response.getOutputStream();
aftaleid = request.getParameter("aftaleid");
name = request.getParameter("name");
byte[] b = getDok(aftaleid, name);
response.setContentType("application/msword");
//response.setContentType(contentType);
if (b != null) {
out.write(b);
}
}
Men jeg får bare "Snavs" ud på skærmen...:
ÐÏࡱá>þÿ <>þÿÿÿ;ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥ÁU@ð¿Ü bjbj¬›¬›%,ÎñÎñÜÿÿÿÿÿÿˆPPPPPPPdh h h h t tde¶ô ô ô ô ô ô ô ô äææææææ$Rm Pô ô ô ô ô PPô ô hhhô ÖPô Pô ähô ähØh@PP@ô è Ð2öÏá Äh Ê @`„50e@ýÔ”ý@ddPPPPýP@ ô ô hô ô ô ô ô dd h hddh
