I have code that works, but sometimes throws a SQL error.
Using a DMI OperationBinding call to a server-side class, I write a PDF file to SQL (Oracle) as a blob.
Here's a code sample:
Occassionally, but not always, I see this SQL error report in the console log:
The Response for the DMI call in the RPC tab of the SGWT Developer console reads:
The console shows an elapsed time of 766ms for the DMI operation.
Tomcat and Oracle are on different servers (VM's) if that matters.
The BLOB update operation always seems to work; the file arrives in SQL; it seems whole, I can read the PDF out of SQL later and there's no corruption or errors, all seems OK.
So I guess my point question is, am I missing some code circa the DSRequest.execute() statement, that would wait or do a Callback, or otherwise close the SQL connection without error?
Any guidance appreciated, thanks.
------------------
SmartClient Version: v8.2p_2013-06-05/PowerEdition Deployment (built 2013-06-05)
IE8
Using a DMI OperationBinding call to a server-side class, I write a PDF file to SQL (Oracle) as a blob.
Here's a code sample:
Code:
// CREATE FILE REFERENCE
File f = null;
try {
f = new File(pdfDir.getPath(), fileName + ".pdf");
} catch (Exception e1) {
transactionOkSoFar = false;
e1.printStackTrace();
}
// ASSIGN FILE TO INPUT STREAM
InputStream inputStream = null;
try {
inputStream = new FileInputStream(f);
} catch (Exception e) {
transactionOkSoFar = false;
e.printStackTrace();
}
// ASSIGN PDF-INPUTSTREAM + METADATA FIELDS TO MAP OF UPDATE VALUES
HashMap<String, Object> values = new HashMap<String, Object>();
values.put("FORM_CS180", inputStream);
// SGWT quirk: IMAGEFILE metadata field-name suffixes MUST BE lower-case
values.put("FORM_CS180_filename", fileName + ".pdf");
values.put("FORM_CS180_filesize", f.length());
values.put("FORM_CS180_date_created", new Date());
// PREP DATASOURCE
DataSource ds_Requests = null;
try {
ds_Requests = DataSourceManager.getDataSource("REQUESTS");
} catch (Exception e2) {
transactionOkSoFar = false;
e2.printStackTrace();
}
// PREP DSRequest
DSRequest req = new DSRequest();
req.setDataSource(ds_Requests);
req.setOperationType("update");
req.setFreeOnExecute(true);
req.setValues(values);
req.setCriteria("REQUEST_ID", data.get("REQUEST_ID"));
// EXECUTE DSREQUEST
try {
DSResponse dsResponse = req.execute();
} catch (Exception e) {
transactionOkSoFar = false;
e.printStackTrace();
}
// CLEANUP
try {
inputStream.close();
} catch (IOException e) {
transactionOkSoFar = false;
e.printStackTrace();
}
// REPORT STATUS TO CLIENT
if (transactionOkSoFar == false) {
response = "FAIL";
}
return response;Code:
//full log attached, but here is the SQL error:
=== 2013-09-04 10:07:14,831 [izer] ERROR SQLConnectionManager - Error attempting to commit and close a connection
java.sql.SQLException: Io exception: Socket closed
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:257)
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:485)
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1254)
at org.apache.commons.dbcp.DelegatingConnection.close(DelegatingConnection.java:214)
at org.apache.commons.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:102)
at com.isomorphic.sql.SQLConnectionManager.free(SQLConnectionManager.java:282)
at com.isomorphic.sql.SQLDriver.freeConnection(SQLDriver.java:138)
at com.isomorphic.sql.SQLDriver.finalize(SQLDriver.java:144)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)Code:
[
{
data:"OK",
invalidateCache:false,
isDSResponse:true,
operationType:"custom",
queueStatus:0,
status:0
}
]Tomcat and Oracle are on different servers (VM's) if that matters.
The BLOB update operation always seems to work; the file arrives in SQL; it seems whole, I can read the PDF out of SQL later and there's no corruption or errors, all seems OK.
So I guess my point question is, am I missing some code circa the DSRequest.execute() statement, that would wait or do a Callback, or otherwise close the SQL connection without error?
Any guidance appreciated, thanks.
------------------
SmartClient Version: v8.2p_2013-06-05/PowerEdition Deployment (built 2013-06-05)
IE8