我正在使用下面的代碼上傳文件到數據庫中的代碼工作正常的圖像,至於其他文件,它不工作我最後發佈堆棧跟蹤。無法上傳文件到數據庫
我的第二個值是一個blob
String strFilePath = null;
Hashtable<Object,Object> fileTable = null;
InputStream input = null;
CosUploadFile file = null;
fileTable = multiPartFormData.getFiles();
file = (CosUploadFile)fileTable.get("filepath");
input =file.getInpuStream();
prepare = connection.prepareStatement("insert into all_files values(?,?,?)");
prepare.setString(1, strFileSplit[0]);
prepare.setBinaryStream(2,input);
prepare.setString(3,strFileSplit[1]);
prepare.execute();
錯誤:
J2CA0206W: A connection error occurred. To help determine the problem, enable the Diagnose Connection Usage option on the Connection Factory or Data Source.
J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adapter for resource datasource. The exception is: java.sql.SQLRecoverableException: Io exception: Connection reset by peer: socket write error:java.net.SocketException: Connection reset by peer: socket write error
com.ibm.websphere.ce.cm.StaleConnectionException: Io exception: Connection reset by peer: socket write error
這是當我試圖上傳doc文件堆棧跟蹤。 我該怎麼辦關於此。
編輯: 下面是我的連接代碼
DBConnect dbConnect = new DBConnect();
Connection connection = dbConnect.connect();
數據庫連接類
public Connection connect()
{
Connection con = null;
try
{
InitialContext context = new InitialContext();
DataSource datasource = (DataSource)context.lookup("datasource");
con = datasource.getConnection("TRAIN2012", "xyz123");
return con;
}
您是否試圖連接到Oracel數據庫?還有什麼數據庫? – bonCodigo
如果你正在存儲圖像或_other files_,它應該沒有什麼區別。請僅對一個文件進行測試。 – Kai
oracle瘦驅動程序10 – sagar