Long row 타입의 이미지파일을 웹상에서 보여주는 방법

* 질문한 사람 : pasture7
* 질문 등록일 : 2001-08-03 16:03:55
* 조회 : 48352
* 답변 : 2건 (kangdk09, aroma123)
-- 질문 내용 --
현재 디비에 long row 타입의 이미지가 들어있습니다.
이미지경로가 들어있는 것이 아니라, 이미지 자체가 들어있거든여.
근데 이걸 resultset으로 불러와서 그 이미지를 웹페이지에 불러오려구 합니다.
getBytes(), getBinaryStream() 은 아예 먹질 않구요..
스트림이 끊길떄두 있습니다.
어케 처리하면 되는지요..
-- 답변 내용 --
1. kangdk09 님의 답변
전체 소스좀 보여주세여..일부분만 보여주니까.. 원인을 찾을수 없겠네염..
일단 스트림이 끊기는 경우는 사용자가 이미지 보다가 취소했을경우나..다른 경우도 있거던여..그리고 코딩상의 문제두 있을수 있구여..
멜루 보내주시면..한번 보구 연락 드리져
[email protected]
2. aroma123 님의 답변
다음의 소스를 참고하세요. 이는 오라클 OSDK에 맟추어 구현되었기 때문에
약간의 수정이 필요할 지 모릅니다. 잘 고쳐서 써보세요.
주의할 것은 res.setContentType( "image/gif" );과 emp1테이블의 portrait가 BLOB으로 저장된 이미지 입니다.
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ImageTest extends HttpServlet
public void doGet( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException
//PrintWriter out = res.getWriter();
res.setContentType( "image/gif" );
ServletOutputStream bout = res.getOutputStream();
try
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver() );
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:ora817",
"scott", "tiger" );
PreparedStatement pstmt = conn.prepareStatement(
"select empno, portrait from emp1 where empno = ?" );
pstmt.setInt( 1, 200 );
ResultSet rset = pstmt.executeQuery();
rset.next();
BLOB blob = ( (OracleResultSet)rset ).getBLOB( 2 );
InputStream fromDB = blob.getBinaryStream();
int bufferSize = blob.getBufferSize();
byte[] buffer = new byte[ bufferSize ];
int length;
while ( ( length = fromDB.read( buffer ) ) != -1 )
bout.write( buffer, 0, length );
fromDB.close();
catch ( SQLException e )
bout.println( "Error" );
bout.println( e.toString() );
}

Similar Messages

  • Too long row

    I display text in sql report. Text has 1000 characters.
    I would display this text in more rows(not recors).I tried set up report/edit TEXT/Tabular Form Element/element width : 20 (for example), but it is not function.
    It is too long row(column TEXT) again.

    Hi,
    Useful Tips to customize Reports.
    1. When a column is huge:
    Contents of some columns are so huge peace of information that it could destroy the look of the report. A possible solution is to set up this column at the end (last in the Query) and extend (“colspan”) it in full report length. For instance let’s suppose that one has six columns and "DESCRIPTION" has several rows of contents.
    SELECT ADDRESS, UNIT_ID, UNIT_PRICE, PRICE, OFFER_NUMBER,
    ('</tr><tr><td colspan="5">' || description || '<hr></td>') "DESCRIPTION"
    FROM OFFERS;
    </tr><tr> will set up a new table row and <hr> will draw a line. Colspan=”5” should be substituted with (count of shown column – 1).
    2. Report is too long (too many columns):
    The solution is similar to the previous one, but the row could be bending on two or more report lines. In the report query for instance set up the following:
    SELECT ID, (SELECT property_subtype FROM property_types WHERE ID = PROPERTY_TYPE_ID) "PROPERTY",
    (SELECT name FROM cities WHERE ID = city) "CITY",
    STREET_ADDRESS, OFF_SIZE, UNIT_PRICE, PRICE,
    ('</td></tr><tr><td>' || DESCRIPTION) "DESCRIPTION",
    ('</td></tr><tr><td>' || GSM || ' ' || FAX || ' ' || PHONE) "GSM", CLIENT_REPRESENTATIVE
    FROM OFFERS;
    The difference here is that the column "DESCRIPTION” is not a last one and you have to set it up in Reports Attributes/Custom/Heading string similar to the one below.
    Id<br>Description<br>GSM
    Property<br>Client Representative
    One could get rid of horizontal rule using Report Template - Borderless.
    I would like to ask every one of the forum "Oracle Database 10g Express Edition".
    What is the primary goal using Oracle XE?
    1. Training (Training)
    2. Production single desktop database (Single)
    3. Production LAN database (LAN)
    4.WEB services database (WEB)
    Please, send me back a word.
    Konstantin
    Message was edited by:
    konstantin.gudjev

  • Problem with a long row for printing

    hi,
    I have a problem with long row in the JTable.
    I want to span the long row into 2 rows so that I can take the print of the table.

    Would it not be easier to wrap the data in the row; you can easilly modify the height of the row in the JTable - setRowHeight().
    Also, if it only affects printing, you could take care of this when you are formatting each line ready for output.

  • How to export long row datatype?

    How to export long row datatype (picture) from database 10g to Microsoft Office Picture Manager?
    Windows XP SP3!

    Extract the long raw fields from your unknown database version into a file:
    Long Raw to file

  • Orace 8.1.7.4.1: LONG ROW

    i've some misanderstandings with LONG ROW type.
    it's needed to copy a LONG VALUE type to a new row in a table, something like this:
    tbl
    id NUMBER;
    data LONG ROW;
    insert into tbl (id, data) values (:id1, (select data from tbl where id=:id2));
    what should i do to make it?
    thnx

    i've some misanderstandings with LONG ROW type.
    it's needed to copy a LONG VALUE type to a new row in a table, something like this:
    tbl
    id NUMBER;
    data LONG ROW;
    insert into tbl (id, data) values (:id1, (select data from tbl where id=:id2));
    what should i do to make it?
    thnx

  • Certain sites are only displaying as long rows of �s - how can this be fixed?

    Quite a few sites or parts of a site - i.e. the captcha on tinypic.com - are only displaying as very one very long, horizontally scrolling row of question marks in black diamonds (�). These sites load perfectly in Safari on my laptop, or on Firefox on my Windows desktop. There are no error messages displayed.

    How much data is being backed-up from each Mac?  (see what's shown for Estimated size of full backup under the exclusions box in Time Machine Prefs > Options).
    Is there any other data on your Time Capsule, besides the backups?
    Most likely, there just isn't room.  Time Machine may be trying to do a very large (or full) backup of one or both Macs, and can't.  Since it won't ever delete the most recent backup, there has to be enough room for one full backup plus whatever it's trying to back up now, plus 20% (for workspace).
    Also see #C4 in Time Machine - Troubleshooting for more details.

  • ORA-22835: buffer too small when trying to save pdf file in LONG RAW column

    Hi,
    I get "ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (real : 125695, maximum : 2000)" when i trying to save a 120k pdf file in an Oracle Long Raw column using dotnet 4.0 and Entity FrameWork.
    Dim db As New OracleEntities
    Try
    Dim myEntity = (From e In db.TEXTE _
    Where e.TEXT_ID = txtTextId.Text _
    Select e).Single
    With myEntity
    If txtTextypeId.Text <> "" Then
    .TEXTYPE_ID = txtTextypeId.Text
    Else
    .TEXTYPE_ID = Nothing
    End If
    .TEXT_NUM = txtTextNum.Text
    .TEXT_NAME = txtTextName.Text
    .TEXT_DATE = dtTextDate.SelectedDate
    If DocAdded Then
    .TEXT_DOC = Document
    ElseIf DocDeleted Then
    .TEXT_DOC = Nothing
    End If
    End With
    db.SaveChanges()
    Document is an array of Byte and TEXT_DOC also (mapped to a long row column).
    is it possible to increase the size of the buffer ? how may i do it ?
    Thx in advance.
    Regards.

    Using a custom UPDATE or INSERT stored procedure for LONG RAW column with
    exceed-limit data may still get the following error.
    "ORA-01460: unimplemented or unreasonable conversion requested".
    One option is to use BLOB instead of LONG RAW in your table and regenerate your
    data model from the table. Then using the default UPDATE or INSERT statement
    (created by EF) should work.
    The following will modify your LONG RAW column to BLOB column.
    Disclaimers:
    1. It's irreversible--you cannot modify BLOB back to LONG RAW.
    2. I have not tried that when there are huge data in LONG RAW column.
    So be careful.
    alter table <your_table_name> modify <your_long_raw_type_column> blob;

  • How to reorder the rows in a table?

    Is it possible to incorporate reordering feature of the SelectOrderShuttle to a table like the following picture?
    http://picasaweb.google.com/lh/photo/c-UAWCac_2ySw_VQj16GEQ?feat=directlink
    Thanks.

    sb92075 wrote:
    The order of columns within row make NO difference to performance; with possible exception of LOB datatypeThat's not strictly true.
    Given a badly designed application you may find a change in column order can make a worthwhile difference to performance. The note in question is aimed specifically at Demantra, and make the following point:
    <ul>
    Due to the way the Oracle RDBMS stores data physically on disk, it is possible to reduce storage and improve performance by rebuilding large tables that have many NULL-value or empty columns, to the end of the row. This is known as reordering.
    </ul>
    This describes a classic bad design - blaming the problems on Oracle, of course.
    But if you do have very long rows (especially with more than 254 columns), and you do leave vary large numbers of columns null, then rearranging the most frequently null columns to the end of the row can make a difference. I've done it a couple of times.
    The OP seems to be talking about the (generally silly) guideline to rebuild the table in primary key order, though, and there is an entertaining (but apparently broken) script that gives a meaningless number that is supposed to show how badly ordered the table is with respect to the primary key. (Personally I would just look at the clustering_factor of the primary key - it's quicker, easier, and more likely to be appropriate).
    Regards
    Jonathan Lewis

  • Photos in Aperture do not wrap in rows, go straight off to right

    Photos in Aperture go right off to the right in one long row.  They no longer wrap in any project.  And NO I don't have filmstrip selected.   I'm well aware of the modes of view.  
    I've seen others with this proble here but the discussions were archived. Any solution?   Very annoying.
    Thanks

    This happened after a power outage.  I've since rebuilt the database, but the problem persists.
    I have each projec exported to a fileshare as a backup - if I needed to re-import all my photos is there a way to point to a file share and say "import all directories each directory being a project"?  I have each project broken out into a directory with all photos in it.   I don't do any editing in Aperture so I don't care about versions.
    Thanks

  • When I have many tabs open, & I am viewing the 1st one in the row of tabs, how can I make ctrl+T open tab next to it instead of down at the end of all the tabs?

    If, for example, I have 50 tabs open, and I happen to be working on the very first tab out of the long row of tabs (tab #1 out of 50 total tabs)....if I suddenly need a new tab next to the one I'm on so that I can do something else related to what I am doing on my current tab's website, pushing ctrl+t opens up the new tab clear down at the very end of the long row of tabs (i.e., the new tab would be tab #51). How can I make the new tab open up right beside the one I'm working on at the moment?

    You would need an extension to achieve this
    You can look at this extension:
    *Tab Utilities Lite: https://addons.mozilla.org/firefox/addon/tab-utilities-lite/

  • Row of an output goes automatically down after printing 1/2 screen?

    I have installed oracle 10g xe R8 in oel 4 which is running on vmware. When i see the records in the table by giving query "SELECT * FROM table_name;" in plsql, then the row of an output shown goes automatically to second line after printing half screen. In this way whole table gets mess i.e. looks irregular.
    thanks in advance

    Did you mean in SQL*Plus?
    SQL*Plus is a very basic command-line tool and doesn't handle wide result sets well without some manual formatting. Also the default settings are not very helpful - I think linesize defaults to a tiny 80 characters and pagesize an absurd 12 lines. Setting linesize to a larger figure will allow longer rows to be displayed without wrapping (although the terminal within which SQL*Plus is running may need adjusting too). However, the describe command unhelpfully adjusts its output to match the current linesize, which is why I use a script desc.sql as a wrapper.
    Of course none of this is relevant if you are not using SQL*Plus.

  • Error when querying long raw

    Hi,
    I am using developer 6i with oracle 10.2.0.4 on win 2008.
    I created a table as below:
    create table image_table (filename varchar2(255) primary key, image long raw);
    i created a trigger in forms to upload a image and store the link in the database. The image is stored in a directory.
    The image link is saved in image_table.
    But when i query the table, i get the below error
    SQL> select * from image_table;
    ERROR:
    ORA-00932: inconsistent datatypes
    no rows selected
    When i query the table in TOAD, i get the output as
    FILENAME, IMAGE
    ateeq, (BLOB)
    Please suggest how to solve this problem.
    Thanks,

    the LONG and LONG RAW datatype have been deprecated in Oracle 8.0, in 1998, so 14 years ago!
    Is there any sound reason why you can't use a BLOB?
    a LONG ROW column can not be displayed directly, so a
    select * from image_table
    where one of the columns is a LONG RAW is expected not to work,
    and if you would have read documentation (which you never do, I remember you from previous doc questions), you would have known and not have asked Yet Another Redundant Question!
    Sybrand Bakker
    Senior Oracle DBA

  • Dynamically convert rows to columns

    I've looked at examples on asktom and here and so far everyone I've seen uses decode() or case() but in all cases you have to know the number of columns.. what if you don't?
    For example:
    select distinct storenbr, pslocation, monthdate, 0 as avg_tran
    from aopschedule.staffing_tran_detail, (select last_day(day) monthdate from days
    where day between to_date('02/01/2008','mm/dd/yyyy') and to_date('5/31/2008','mm/dd/yyyy'))
    where pslocation = '1110'returns
    STORENBR     PSLOCATION     MONTHDATE     AVG_TRAN
    34806     1110     2/29/2008     0
    34806     1110     3/31/2008     0
    34806     1110     4/30/2008     0
    34806     1110     5/31/2008     0But the date range is dynamic...
    So how do I account for this?
    I need this to look like
    storenbr     pslocation    feb    mar     apr    may
    12345        1234          0      0       0      0
    12399        2222          2      1       1      1
    ...I have Oracle 9i. Thanks
    Message was edited by:
    GM

    Hi,
    As Justin said, the number of columns is fixed when the query is compiled.
    Without doing dynamic SQL, you can provide for a worst case. For example, you can write a query that always has columns fro 12 months. If you run the query with parameters such that only three months are needed, the other nine columns will be NULL. This is not especially pretty, but it's relatively easy.
    You can do a truly dynamic querry In SQL*Plus. Instead of hard-coding a query such as
    SELECT storenbr
    , pslocation
    , SUM (DECODE (n, 1, cnt)) AS col_1
    , SUM (DECODE (n, 2, cnt)) AS col_2
    FROM staffing_tran_detail
    you can put the text shown in bold above (whether it's two columns, as in the example above, or three, or twelve) into a substitution variable. To define that substitution varibale dyamically, use the SQL*Plus "COLUMN ... NEW_VALUE" command, and run a preliminary query (which can be in the same script) to define the variable. If this involves concatenating multiple short rows of output into one very long row, there are a number of string aggregation techiques, such as the user-defined STRAGG function.
    Like Justin said, this is not trivial. If you're serious about doing it, post as much code as you can (such as a query with three hard-coded columns), and ask for help with the next step.

  • Converstion Long raw to BLOB

    Hello All,
    I am using Oracle 10g,
    I need to alter a table which have a Long row data type column, i want to modify the data type of this column to BLOB.
    This table contains data, does this alteration affect the data of the table in any way?
    Regards,

    Any information ? if the alteration of the LONG RAW data type to BLOB affect the existing data ?
    Thanks in advance ,

  • Export to text and chr(13)||chr(10)

    Hi All,
    I have report (10g) and one column that formatted by PL/SQL to have multiply rows in it. This achieved by adding chr(13)||chr(10) to the row, so I have multiply rows result on report output.
    But when the same report is exported to text file, then chr(13)||chr(10) are ignored and result is one long row instead multi-rows…
    Is the way to overcome such result in export?
    Thank you.
    Edited by: user555411 on Nov 10, 2008 8:02 AM

    You can get multiple lines by using repeating frames. That's on the line level.
    On the field level, for example, if you have a varchar2 field containing string with 50 characters, but want to display in two lines, you can add a field in report layout that is not long enough for 50 char, but make the length of the box vertically variable in Property Palette. So when there is not enough space to show the whole string, it will go to next line.
    You can try this if inserting chr(13) or chr(10) can't do what you want.

Maybe you are looking for

  • How to solve error c1190 : MFC requires to use Winsock2.h ?

    in the name of allah hi everyone i work with visual C++ 2008 and i'm a project that contains the c and c++ code together. the project worked correctly but when i add a .cpp and a .h file to the project, the project errors the c1189 : MFC requires to

  • WAD Variable Screen

    Hi Gurus,    I'm working on BW WAD, we have a requirement to enhance Variable screen in WAD. Is there any way, i can customize for better look and feel. If its possible, how can I do that? any kind of help will be great. Thanks, Deepak Kunavarapu

  • Adobe Muse Middle Eastern version

    So i've been searching for answers all over - and got mixed answeres.  The question is simple this: Can I, or can I not - design a website with Adobe Muse that is fully in Hebrew?

  • Help Enable Bluetooth

    Hello fellow apple-users, I was hoping to find some help in regards to a mistake I made about a year ago. I was finding that my roommate was using the bluetooth on my macbook pro to upload pictures of himself to his many overweight internet "girl"fri

  • For PPC users that want to install Windows

    I came across this little gem today while surfing the net. http://www.microsoft.com/mac/products/virtualpc/highlights.aspx It's a Virtual PC tool for G5 Mac users. And it also supports Tiger (in case you didn't upgrade to Leopard yet). It's $129 for