Blob Storage, DB looses connection
Posted: Thu 04 Jun 2009 17:57
I am trying to store 8 MB video files in a MySQL db using UniBlob and the method outlined in the UniDirect tutorial for blob storage. The blob storage works for small data files, 10K or so, but when I try to store a 8MB video file, I receive an "Database lost connection" error message.
The data item in the MySql table is defined as:
file_data LONGBLOB DEFAULT NULL
The code for storing the video file is (C# .NET):
FileStream fs = new FileStream(blobFilename, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
int streamLength = (int)fs.Length;
UniBlob uniBlob = db.getUniBlob();
uniBlob.Write(r.ReadBytes(streamLength), 0, streamLength);
string cmdString = "INSERT INTO eventData ";
cmdString += "(event_id, file_data) ";
cmdString += "VALUES(";
cmdString += "'" + eventList.eventID.ToString() + "',";
cmdString += ":file_data)";
UniCommand uCmd = db.GetCommand(cmdString, CommandType.Text);
UniParameter myParam = uCmd.Parameters.Add("file_data", UniDbType.Blob);
myParam.Value = uniBlob;
uCmd.ExecuteNonQuery();
Any suggestions of what I might be doing wrong?
Thanks for your help.
The data item in the MySql table is defined as:
file_data LONGBLOB DEFAULT NULL
The code for storing the video file is (C# .NET):
FileStream fs = new FileStream(blobFilename, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
int streamLength = (int)fs.Length;
UniBlob uniBlob = db.getUniBlob();
uniBlob.Write(r.ReadBytes(streamLength), 0, streamLength);
string cmdString = "INSERT INTO eventData ";
cmdString += "(event_id, file_data) ";
cmdString += "VALUES(";
cmdString += "'" + eventList.eventID.ToString() + "',";
cmdString += ":file_data)";
UniCommand uCmd = db.GetCommand(cmdString, CommandType.Text);
UniParameter myParam = uCmd.Parameters.Add("file_data", UniDbType.Blob);
myParam.Value = uniBlob;
uCmd.ExecuteNonQuery();
Any suggestions of what I might be doing wrong?
Thanks for your help.