How can i load file into database from client-side to server-side

i want to upload file from client-side to server-side, i use the following code to load blob into database.
if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
how can i solve it without upload the file to the server first, then load it into database??
try
ResultSet rset = null;
PreparedStatement pstmt =
conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
pstmt.setInt (1, docId);
pstmt.execute ();
// Open the destination blob:
pstmt.setInt (1, docId);
rset = pstmt.executeQuery (
"SELECT content FROM docs WHERE id = ? FOR UPDATE");
BLOB dest_lob = null;
if (rset.next()) {
dest_lob = ((OracleResultSet)rset).getBLOB (1);
// Declare a file handler for the input file
File binaryFile = new File (fileName);
FileInputStream istream = new FileInputStream (binaryFile);
// Create an OutputStram object to write the BLOB as a stream
OutputStream ostream = dest_lob.getBinaryOutputStream();
// Create a tempory buffer
byte[] buffer = new byte[1024];
int length = 0;
// Use the read() method to read the file to the byte
// array buffer, then use the write() method to write it to
// the BLOB.
while ((length = istream.read(buffer)) != -1)
ostream.write(buffer, 0, length);
pstmt.close();
// Close all streams and file handles:
istream.close();
ostream.flush();
ostream.close();
//dest_lob.close();
// Commit the transaction:
conn.commit();
conn.close();
} catch (SQLException e) {

Hi,
Without some more details of the configuration, its difficult to know
what's happening here. For example, what do you mean by client side
and server side, and where are you running the upload Java application?
If you always run the application on the database server system, but can't
open the file on a different machine, then it sounds like a file protection
problem that isn't really connected with the database at all. That is to
say, if the new FileInputStream (binaryFile) statement fails, then its not
really a database problem, but a file protection issue. On the other hand,
I can't explain what's happening if you run the program on the same machine
as the document file (client machine), but you can't write the data to the
server, assuming the JDBC connection string is set correctly to connect to
the appropriate database server.
If you can provide some more information, we'll try to help.
Simon
null

Similar Messages

  • How can upload doc file into database !!

    Dear Everyone,
    How can i upload a doc file into Mysql database ....
    can any one please give ur suggestions...
    i will show u my code
    upload.jsp
    <form name="uploader" action="uploaded.jsp"
    enctype="multipart/form-data">
      <div align="center">
      <table id="table1" border="1" bordercolor="#ff0000"
    cellpadding="0" cellspacing="0" width="50%">
        <tbody bgcolor="#c8d8f8">
          <tr>
            <td bgcolor="#ccccff">
            <p align="center">
               Resume Upload! </p>
            </td>
          </tr>
          <tr>
            <td> 
            <p align="center">You can upload your
    resume.. </p>
            <p align="center">
            <table align="center" border="1"
    cellpadding="10" cellspacing="10">
              <tbody>
                <tr>
                  <td>
                  <p><input name="file" type="file">
                  <input name="uploadButton" value="Upload"
    type="submit"></p>
                  </td>
                </tr>
              </tbody>
            </table>
            </p>
            </td>
          </tr>
        </tbody>
      </table>
      </div>
    </form>
    uploaded.jsp
    <BODY>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <% 
        String file1=request.getParameter("file");
        int len;
        String query;
        PreparedStatement pstmt;
       int i=0;
        Class.forName("com.mysql.jdbc.Driver");
    DriverManager.getConnection("jdbc:mysql://localhost:3306    Connection conn= /employee","root","");
         try {
                File file = new File(file1);
                   if (file==null)
    %>
    <center>Nothing in It</center>
    <%
                else
                FileInputStream fis = new FileInputStream(file);
                len = (int)file.length();
                query = ("insert into loader(resume) VALUES(?)");
                pstmt = conn.prepareStatement(query);
                pstmt.setString(1,file.getName());
                pstmt.setInt(2, len);
                //method to insert a stream of bytes
                pstmt.setBinaryStream(3, fis, len);
              i=pstmt.executeUpdate();
                   if(pstmt!=null)
                 pstmt.close();
                if(conn!=null)
                 conn.close();
            } catch (Exception e) {
                e.printStackTrace();
                 if(i>0)
                        out.println("uploaded");
                    else
                        out.println("not uploaded")
    %>
    </BODY>

    File file = new File("myDoc.doc");
    FileInputStream fis = new FileInputStream(file);The file name will most likely NOT be hard-coded. I don't think the question surrounding this topic is how to do the insert statement (he/she clearly knows SQL).
    HTTP and the web browser take care of the file transfer, but the server stores the file in a temporary location. The question is, "How do I found out that location?" In PHP (I know that doesn't offer much help to you, but ...), that location is held in a variable called $_FILES. From there you can simply copy the file to a location you specify (probably with a user-specified name under a directory specifically for that user).
    I hope this is of some help:
    http://www.oop-reserch.com/mime_example_4.html
    Good Luck,
    C. R.

  • How can I load up some pdfFiles from adobe Reader on my iPad into my Adobe Creative Cloud?

    How can I load up some pdfFiles from adobe Reader on my iPad into my Adobe Creative Cloud?

    There is no app for uploading files from an iPad to the Adobe Creative Cloud, and the iPad security model does not allow for upload of files from the browser. The Adobe Touch Apps do provide syncing up to the Creative Cloud but none of them are really designed for working with pdf files.
    You can connect your iPad and move the files to your computer. From your computer you can upload the files via a web browser.

  • How can I load data into table with SQL*LOADER

    how can I load data into table with SQL*LOADER
    when column data length more than 255 bytes?
    when column exceed 255 ,data can not be insert into table by SQL*LOADER
    CREATE TABLE A (
    A VARCHAR2 ( 10 ) ,
    B VARCHAR2 ( 10 ) ,
    C VARCHAR2 ( 10 ) ,
    E VARCHAR2 ( 2000 ) );
    control file:
    load data
    append into table A
    fields terminated by X'09'
    (A , B , C , E )
    SQL*LOADER command:
    sqlldr test/test control=A_ctl.txt data=A.xls log=b.log
    datafile:
    column E is more than 255bytes
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)

    Check this out.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006961

  • How can I import music into iTunes from other media .I have music which was downloaded from my Sony Ericcson W715 into "Media Go" and I want to transfer it into iTunes.Is this possible ?

    How can I import music into iTunes from another media.
    I have a library downloaded from a Sony Ericsson W715 into "Media Go" and I want to transfer to iTunes and then into my iPhone 4.
    Is this possible ?
    Chris
    <Email Edited by Host>

    chrisfromgoodworth clatford wrote:
    How can I import music into iTunes from another media.
    I have a library downloaded from a Sony Ericsson W715 into "Media Go" and I want to transfer to iTunes and then into my iPhone 4.
    Is this possible ?
    Chris
    Possibly. Media Go supports a variety of music formats, some of which can be imported in to iTunes and then synced on to an iPhone, however some of its formats cannot be imported in to iTunes.
    See http://mediago.sony.com/enu/supported-file-formats/ for a list of formats supported by Media Go. iTunes for Windows supports MP3, AAC, WAV, and can import and convert WMA files as well. However iTunes does not support ATRAC, or FLAC.
    Furthermore, if some of your music has been bought from an Internet music store it might be procted by DRM. If so it cannot be imported in to iTunes.
    To do the importing you would either drag the music files in to iTunes, or tell iTunes to open them. See http://support.apple.com/kb/ht1347

  • Hi, I am user iPad and I do not know how can attach a file into email e.g. CV.  Thanks

    Hi,
    I am user iPad and I do not know how can attach a file into email e.g. CV. 
    Thanks

    You attach files within the app that creates the file or within the app that the file is saved. For example you email photos from within  the Photos App itself. Typically there will be an action icon within the app - an arrow icon many times - you tap on that to bring other options like Share - then Email.
    Attachments must be mailed within the apps themselves.

  • How can I copy movies into iPhone from my PC?

    How can I put movies into Iphone from PC.
    When I'm trying to put video files into library (mp4 format) it not appear in my iTunes library.

    You sync it to your iPad.
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%204/9d04e8509b150edc93a 9a8b2adc4dc59.jpg

  • How can I connect to a database from ipaq with cldc??

    how can I connect to a database from ipaq with cldc??

    Hi Again
    There is a library by Mimer which allows you do connect to a Mimer SQL Server, don't know must about it, but here is a link.
    http://developer.mimer.com/
    If that doesn't suit you, I suspect that you will have to use some sort of proxy solution. Either by creating a servlet to accept the sql string you want to send, or by creating your own custom proxy server running J2EE. The servlet or the proxy server must be able to receive an SQL String, do the query to the actual database and return the results in some sort of format to the mobile device. Maybe just a space delimited string.
    Hope this helps
    -Daur

  • How can I import video into iMovie from a DVD?

    How can I import video into iMovie from a DVD?
    Thanks,
    Doug Davis

    You can do this with a free app called MPEG Streamclip and a $20 quicktime component from Apple.
    See detailed instructions here.
    https://discussions.apple.com/docs/DOC-3951

  • How can I send files via Bluetook from my Tour to other phones?

    How can I send files via Bluetook from my Tour to other phones?
    I have even been able to pair to the other device, but I don't see the option to send/copy/move files through Bluetooth.
    I can only send my Address book via bluetooth.
    Please help!!

    Hi and Welcome to the Community!
    See this KB:
    KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
    Substitute, in the KB, the appropriate instructions for your other device in place of the KB section for the receiving device. Be aware that RIM only supports BT file transfer between BBs...with other devices is technically unsupported. But, it usually works, as long as the two devices are paired, trusted to each other, and each have all of the correct BT services enabled for the configuration of the other device.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How can I import file of photos from external drive into photoshop elements 11 organizer?

    I just started with elements 11 after many years of El., 10. How can I import files from external disk to elements 11 organizer? My files were stored on the external drive.

    Hi,
    The Canon S100 wasn't supported until version 6.6 of camera raw and that isn't supported by pse 8.
    You options are to either upgrade to pse version 10 or use the DNG converter
    for windows http://www.adobe.com/support/downloads/detail.jsp?ftpID=5310
    or
    for mac http://www.adobe.com/support/downloads/detail.jsp?ftpID=5309
    Brian

  • How do you "load files into photoshop layers" in bridge cc

    I am having difficulty following on instruction in learning photoshop cc.
    The book says to load files as layers select(in Bridge) tools/photoshop/Load files into photoshop Layers.
    There is no Photoshop Option in the Tools Menu in my Bridge CC.
    Is ther another way?
    Dave

    I run Windows 7 Ultimate, I have 2.00GB of RAM with 1.74 usable, and I selected 40 images, each about 2MB.

  • How can I transfer files and settings from a PC to a mac

    How can I transfer data and settings from PC to mac via cable as the method via the network seems excessively slow. What cables do I need Ethernet USB?

    This Apple Article may help.

  • Storing  WAVE file into database from sql plus.

    dear all
    I have create a table with two attributes,sl_no number and song long raw type.
    what will be the insert command to insert a .wav file into the database.if not then you can give me some alternate solution also.
    thanks.

    You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
    The documentation can be found on technet at
    urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
    [\url]
    An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
    Good Luck,
    Eric Kamradt

  • How can we upload file into to OCS Content repository when we are in Apex

    We have installed the Oracle Application Express 2.2.1 into the OCS 10.1.2 database.
    The Apex authentication is set to operate with OCS SSO.
    We have made a form. There is a browse button on the form. We would like if the uploaded file appeared in the OCS content database repository as
    opposed to Apex document repository.
    To put it into another word, how can we upload the file into to OCS Content repository when we are in Apex.
    Generally speaking, how can we reach content from Apex?
    We have found many java based examples to use content sdk, but how can we use them with Apex? We believe that
    content hasn't got plsql interface.
    i would highly appreciate it if you sent me a full example program.

    Hi Ram,
    Thanks for the reply
    We have a requirement to device a solution to upload the policy documents related to iProcurement
    I am planning to create an OA page to upload the content and planning to use the AOL function security to restrict the users those who can access this page .
    Is there any better way to implement the security?
    Is this approach feasible or is there any better way to approach this requirement?
    Thanks

Maybe you are looking for

  • Safari Crashing Constantly

    I haven't been a Mac user for long so any help anyone could give me would be appreciated. My safari keeps crashing randomly to the point that it is becoming extremely frustrating. Here is a report: Thanks! Process: Safari [683] Path: /Applications/Sa

  • How can I tell if my MacBook Pro has a Retina display?

    I am happy to say, that I am the PROUD OWNER of a 15" MacBook Pro and I don't know if the one that I have has a Retina display built into it. I was looking on the forums, to see if I might be able to get away with installing a copy of Windows 7 Pro (

  • Why my iphone4s have no facetime?instead of facetime, it changed to face dial.. what will i do?

    how can i dowload facetime? bec i bought a iphone4s have no facetime instead of facetime, i think all iphone4 s have the same but its not bec the other iphone have no facetime so bad that i bought the wrong one

  • Pics out of focus in viewer

    Aloha, when I 1)Load in new photos from my camera and 2) view any photo in my library in my viewer at any time, it is out of focus. I have to slide the slider even just a little bit and it brings the pic into focus. When I am looking at a new roll pi

  • Xcode 3 Errors

    Hello, I have been working with GLUT in my graphics class all semester using 2.4, and it has been going great, most of the other students had to go get GLUT, and install it, Apple was kind enough to include it with the dev tools, and it works very we