into the blob.
To retrieve we have this JSP page. This allows a direct stream read to the
browser and does not write the file to the system and then attempt to read
it. But we have code that does that as well if you need to look at it also.
This is a JSP page so you must be running MX for this to work (or a JSP
alternative)
<%@ page import="java.sql.*"%>
<%
String strId=request.getParameter("id");
String strTable=request.getParameter("table");
String strUidField=request.getParameter("uidfield");
String strUsername=request.getParameter("username");
String strPassword=request.getParameter("password");
String strHost=request.getParameter("host");
String strPort=request.getParameter("port");
String strSid=request.getParameter("sid");
if (strUidField==null | strUidField.equals(""))
{
response.setContentType("text/html");
out.println("URL UidField does not exist or is blank.");
return;
}
if (strId==null | strId.equals(""))
{
response.setContentType("text/html");
out.println("URL ID does not exist or is blank.");
return;
}
if (strTable==null | strTable.equals(""))
{
response.setContentType("text/html");
out.println("Table name does not exist or is blank.");
return;
}
if (strUsername==null | strUsername.equals(""))
{
response.setContentType("text/html");
out.println("Username does not exist or is blank.");
return;
}
if (strPassword==null | strPassword.equals(""))
{
response.setContentType("text/html");
out.println("Password does not exist or is blank.");
return;
}
if (strHost==null | strHost.equals(""))
{
response.setContentType("text/html");
out.println("Host does not exist or is blank.");
return;
}
if (strPort==null | strPort.equals(""))
{
response.setContentType("text/html");
out.println("Port does not exist or is blank.");
return;
}
if (strSid==null | strSid.equals(""))
{
response.setContentType("text/html");
out.println("Sid does not exist or is blank.");
return;
}
Class.forName("oracle.jdbc.driver.OracleDriver");
//String str_url = "jdbc oracle:thin:@gops_test:1521:GOPS";
//String strUsername="<blah>";
//String strPassword="<blah>";
//String strHost="<Host name>";
//String strPort="<Port Number>";
//String strSid="<SID Name>";
//String strTable="<Table Name>";
String str_url =
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + strHost +
")(PORT =" + strPort + "))(CONNECT_DATA=(SID=" + strSid + ")))";
Connection con =
DriverManager.getConnection(str_url,strUsername,strPassword);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM " + strTable +
" where " + strUidField + "=" + strId );
int isGood=0;
boolean isText=false;
if (rs.next())
{
String dim_image = rs.getString("EXT");
if (dim_image==null)
{
response.setContentType("text/html");
out.println("Media for this ID is
empty.");
return;
}
dim_image = dim_image.toUpperCase();
if ( dim_image.equals("JPG") )
{ isGood=1;
response.setContentType("image/jpeg"); }
else if ( dim_image.equals("TIF"))
{ isGood=1;
response.setContentType("image/tiff"); }
else if ( dim_image.equals("GIF"))
{ isGood=1;
response.setContentType("image/gif"); }
else if ( dim_image.equals("BMP"))
{ isGood=1;
response.setContentType("image/bmp"); }
else if ( dim_image.equals("PDF"))
{ isGood=1;
response.setContentType("application/pdf");
response.addHeader("Content-disposition", "inline;filename=\"file.pdf\"");
}
else if ( dim_image.equals("MAX"))
{ isGood=1;
response.setContentType("application/max");
response.addHeader("Content-disposition", "inline;filename=\"file.max\"");
}
else if ( dim_image.equals("XLS") |
dim_image.equals("CSV"))
{ isGood=1;
response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-disposition", "inline;filename=\"file.xls\"");
}
else if ( dim_image.equals("XLS") |
dim_image.equals("DOC"))
{ isGood=1;
response.setContentType("application/msword");
response.addHeader("Content-disposition", "inline;filename=\"file.doc\"");
}
else if ( dim_image.equals("MP3"))
{ isGood=1;
response.setContentType("audio/x-mpeg3");
response.addHeader("Content-disposition", "inline;filename=\"file.mp3\"");
}
else if ( dim_image.equals("HTM") |
dim_image.equals("HTML") | dim_image.equals("TXT") )
{
isGood=1;
isText=true;
response.setContentType("text/html");
}
else
{
response.setContentType("text/html"); out.println("No attached media to
display or unsupported format."); }
if (isGood==1)
{
if (!isText)
{
ServletOutputStream op = response.getOutputStream();
Blob
blob;
blob
= rs.getBlob( "PICTURE" );
System.out.println("PICTURE");
int
iLength = (int)(blob.length());
op.write(blob.getBytes( 1, iLength ));
}
else
{
java.io.PrintWriter op=response.getWriter();
//
op.write("hi");
//out.println("hi");
Blob
blob;
blob
= rs.getBlob( "PICTURE" );
int
iLength = (int)(blob.length());
byte
[] data = "" iLength);
for
(int i = 0; i < iLength; i++)
{
byte
b = data[i];
//out.println(b);
op.write(b);
}
}
}
}
else
{
response.setContentType("text/html");
out.println("No attached media to display.");
}
rs.close();
stmt.close();
con.close();
%>
Stephen E. Schuster
PeopleSoft Administrator
2000 Ashland Drive
Ashland, KY 41101
Office Phone 606.920.7447
Cell Phone 606.831.4590
_____
From: Schuster, Steven [mailto:[EMAIL PROTECTED]
Sent: Friday, January 09, 2004 12:40 PM
To: CF-Talk
Subject: RE: Images - store in DB or filesystem?
Well I'm not sure about taking up less size at all. Now given you will have
to create an initial database but minus that it's just data. Regardless if
you go this route the space differences would be minimal.
If you want I can post the JSP code we use for retrieval?
Stephen E. Schuster
PeopleSoft Administrator
2000 Ashland Drive
Ashland, KY 41101
Office Phone 606.920.7447
Cell Phone 606.831.4590
_____
From: Charlie Griefer [mailto:[EMAIL PROTECTED]
Sent: Friday, January 09, 2004 11:04 AM
To: CF-Talk
Subject: Re: Images - store in DB or filesystem?
Hi Steven:
I'll have to defer to your experience here, as my answer was based only on a
response I got from an instructor when asking him this same question...so
I've always done it the text datatype/file path method.
Maybe 'bloat' was too strong of a word? Maybe he just meant that storing
the images as files would take up -less- space than storing them as BLOBs?
Charlie
----- Original Message -----
From: Schuster, Steven
To: CF-Talk
Sent: Friday, January 09, 2004 8:47 AM
Subject: RE: Images - store in DB or filesystem?
I can assure you that storing images in BLOB does not bloat a database.
They
are designed for this very thing. Though I will admit that Oracle is far
better than SQL Server at doing it. I have never really dealt with mySQL
and
it's been years since I used Informix so I can't tell you much on those
products.
We do this for our fax apps. We store all types of data in Oracle BLOBS
and
it is actually faster than file writes. We use a JSP page to do the pulls
and puts. In fact we even integrated it into our PeopleSoft product so
that
our remote locations can now just fax in new hire documents, the faxes go
directly to the database and are available for viewing through the Job
panel
in PS.
Stephen E. Schuster
PeopleSoft Administrator
2000 Ashland Drive
Ashland, KY 41101
Office Phone 606.920.7447
Cell Phone 606.831.4590
_____
From: Charlie Griefer [mailto:[EMAIL PROTECTED]
Sent: Friday, January 09, 2004 10:42 AM
To: CF-Talk
Subject: Re: Images - store in DB or filesystem?
I've always heard path in text fields. From what I understand, storing as
BLOBs will bloat the db, and it's rather slow.
----- Original Message -----
From: Spectrum WebDesign
To: CF-Talk
Sent: Friday, January 09, 2004 8:15 AM
Subject: Images - store in DB or filesystem?
What's the in/out for image storage? Bynary in BLOB database fields or
file system or path in text fields?
----- Original Message -----
From: "Pascal Peters" <[EMAIL PROTECTED]>
Date: Fri, 9 Jan 2004 15:40:16 +0100
To: CF-Talk <[EMAIL PROTECTED]>
Subject: RE: insert multiple drop down list selects into access
Looks like you want a one-to many relationship. Create a second table
for
that (with a FK to the existing table). Then loop over the list and insert
in the second table within the loop (using the PK from the record in the
first table as FK in the second table)
-----Oorspronkelijk bericht-----
Van: Tim Laureska [mailto:[EMAIL PROTECTED]
Verzonden: vr 9/01/2004 15:15
Aan: CF-Talk
CC:
Onderwerp: insert multiple drop down list selects into access
Is it possible to insert into one access database number field, a comma
delimited list of numbers, received from a form template thusly (is not
working now ... only can one number to show in the database when
multiples are selected on the form drop down):
FORM CODE:
<select name="cat_no" multiple>
<cfoutput query="client_cat"><option
value="#cat_no#">#work_cat#</cfoutput>
</select>
TEMPLATE WHERE DATABASE INSERT IS HAPPENING:
<cfquery datasource="todo" dbtype="odbc">
INSERT into clients (category)
VALUES (#cat_no#)
</cfquery>
TIA
Tim
_____
_____
_____
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

