{
theLog.printDebugInfo("--getaudio started");
java.sql.Connection con=null;Statement stmt=null;
- byte[] img_data=null;
+ byte[] data=null;
try {
con = theStorageObject.getPooledCon();
if(rs!=null) {
if (rs.next()) {
LargeObject lob = lom.open(rs.getInt(1));
- img_data = lob.read(lob.size());
+ data = lob.read(lob.size());
lob.close();
- //img_data = rs.getBytes(1);
+ //data = rs.getBytes(1);
}
rs.close();
}
theStorageObject.freeConnection(con,stmt);
}
- return img_data;
+ return data;
}
- public void setAudio(byte[] audioData, String audioType)
+ public void setAudio(byte[] uploadData)
throws StorageObjectException {
- if (audioData!=null) {
+ if (uploadData!=null) {
java.sql.Connection con=null;PreparedStatement pstmt=null;
try {
- theLog.printDebugInfo("settaudio :: making internal representation of audio");
- theLog.printDebugInfo("settaudio :: made internal representation of audio");
- theLog.printDebugInfo("settaudio :: getAudio");
-
- if ( audioData!=null) {
+ if (uploadData!=null) {
con = theStorageObject.getPooledCon();
con.setAutoCommit(false);
- theLog.printDebugInfo("settaudio :: trying to insert audio");
+ theLog.printDebugInfo("setaudio :: trying to insert audio");
// setting values
- pstmt.setBytes(1, audioData);
- String sql="update content set is_produced='0' where to_media="+getId();
+ LargeObjectManager lom;
+ java.sql.Connection jCon;
+ jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
+ .getNativeConnection();
+ lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
+ int oid = lom.create();
+ LargeObject lob = lom.open(oid);
+ lob.write(uploadData);
+ lob.close();
+ String sql = "update images set"
+ +" audio_data="+oid
+ +" where id="+getId();
+ theLog.printDebugInfo("setaudio :: updating: "+ sql);
+ pstmt = con.prepareStatement(sql);
+ //pstmt.setBytes(1, imageData);
+ //pstmt.setBytes(2, iconData);
+ pstmt.executeUpdate();
+ sql="update content set is_produced='0' where to_media="+getId();
pstmt = con.prepareStatement(sql);
pstmt.executeUpdate();
}
}
- catch (Exception e) {throwStorageObjectException(e, "settaudio :: setAudio gescheitert: ");}
+ catch (Exception e) {
+ throwStorageObjectException(e,"setaudio ::failed: ");
+ }
finally {
try { if (con!=null) con.setAutoCommit(true); } catch (Exception e) {;}
theStorageObject.freeConnection(con,pstmt); }
}
}
+
public void update() throws StorageObjectException {
super.update();
try {