How to store a filepath in a database??

hi,
Somewhere in my program i have to store a path that i'll need later to load an image into a label at runtime. But, when i try to store it, in mysql, it doesn't take the escape character, i mean if i try to store "e:\mydocs", my fuction call only stores : "e:mydocs". I'm trying to put the escape char in the DB but i can't. I'm using that call:
path.getText()
where path is a textbox. I'm using the mm driver for my connection, and i'm sure the problem is that when i store the path, in the DB, it doesn't store the escape char, the escape char doesn't appears when i make a query. Because of that i can't load the image later...
Hope someone faced this problem before, 'cause i really need an answer ;)

No, that wouldn't make any difference because there
aren't any special characters or escape characters in
the strings you claim you are having trouble with.
In fact if you do what you say you are doing, you
should not have the problem you say you have. So it
follows you are doing something else that you haven't
said. The only circumstance in which backslash
characters will "disappear" is when you use them in
string literals in your Java code, and that's what I
guess you have done.
In your Java code you need to write "e:\\mydocs" as a
string literal to represent the string "e:\mydocs".
This is ONLY in Java code, though, you should type
"e:\mydocs" into the text box.The special character appears in runtime execution and is passed to the DB after the "xxx.getText()". So, from here, it passes the backslash into the java code and from there it goes to the DB.
I couldn't use the "e:\\mydocs" expression cause the path doesn't come this way at runtime...
So to make it work , i used two functions that i made :
one of them to encode the string and the other one to decode it :
public String encode(String caminho) {
if (caminho==null)
return null;
int length = caminho.length();
StringBuffer codifica = new StringBuffer(2 * length);
for (int i=0; i<length; i++) {
char c = caminho.charAt(i);
if (c=='\\')
codifica.append("%");
else
codifica.append(c);
return codifica.toString();
public String decode(String caminho) {
if (caminho==null)
return null;
int length = caminho.length();
StringBuffer codifica = new StringBuffer(2 * length);
for (int i=0; i<length; i++) {
char c = caminho.charAt(i);
if (c=='%')
codifica.append("\\");
else
codifica.append(c);
return codifica.toString();
where i use the encode to store the path and the decode to retrieve it later. It'worked, but do you know if there's a java function that does the same thing???

Similar Messages

  • Chat App: how to store the user IP in database when they login.

    hello,
    i am working on chat application. first i made a login GUI form. after login when we run the Chat program, it ask the ip address of the server to whom it want to connect. and if u enter the ip address, it will connect to the server and chat will begin, thats working perfect.
    but i want to show the list of users who r logged on and when i simply click on the user name, chat should begin.
    i have the logic that when any user log in, then its IP address will be stored in the database. this ip address will shown to the online users.
    but i dont know how to store the user information in database when they log in. can any body suggest me wht lines of code i should use.
    thanks.

    palakk wrote:
    i have the logic that when any user log in, then its IP address will be stored in the database. Bad approach. That will only work if this chat is only intended for use on a LAN. If it's used on the internet, then your users' IP addresses will almost always be either a) those of their routers, or b) private IP addresses, and in both cases, multiple users can have the same IP address.
    this ip address will shown to the online users. Why would you want to do that? I want to chat with "Bill", not with "1.2.3.4".
    but i dont know how to store the user information in database when they log in.Do the same thing that you're currently doing to store the IP address, but with the other information you want to store.
    can any body suggest me wht lines of code i should use. This is not a code writing service.

  • How to store image in the oracle database 10.2. using File Maker 10.

    Hi.,
    I want to store image, media file in the oracle database using File Maker as a front end.
    I connect Oracle using odbc from file maker. There are table and in that table there a column "pict" of blob type. but this column is not showing in the file maker.
    2. Here I can not change the data type of any column.
    Now how to store images in the oracle table using odbc or any other tool.
    Regards,
    Shyam

    I wrote an example for my students, you can find it here. It's using PHP as the front end but all you need to do is know how and leverage the stored procedures. All code is downloadable in zip files from the blog.
    http://blog.mclaughlinsoftware.com/php-programming/oracle-lob-processing/

  • How to store a signature file in database oracle 8.0

    hai,
    please send a sample code how to store a signature stored in a flat file a.gif,b.tif into oracle database please send me the script to [email protected]
    please help me any one

    Hi,
    Read the Articles in the Documentation regarding BFILE. There is a Beautiful example on the docs.
    You can also BLOBS to store these images in the database.
    Best of Luck.
    regards,
    Ganesh R

  • How to store forms and reports in database

    Hi friends,
    How to store the forms and reports in database?
    when i save a form in database it doesnt prompt with any message
    and when i try to retrieve from the list it prompts me with a
    message
    can anyone suggest me the methods of storing the forms in the
    database and retriving from it.
    Jagadeesh
    null

    I believe this will help you
    To store forms & Reports in Database you need to run some
    scripts which are shipped with Oracle
    To install the SQL scripts:
    Start the Oracle Installer and select Custom Installation or
    Removal from the Oracle Developer Installation Options dialog
    box.
    Select Oracle Developer Database Tables from the Available
    Products list.
    Click Install.
    Installing these scripts creates a Start menu item called Oracle
    Developer R6.0 Admin and the associated submenu items Oracle
    Developer Build, Oracle Developer Drop, Oracle Developer Grant,
    and Oracle Developer Revoke. These menu items, when selected,
    run a script or a series of scripts to perform database
    administration tasks.
    Note: I tried to store forms in the database by creating tables
    but in forms fmb will store in database & fmx will store on
    clients machine so you have to install fmx on all client machines
    I tried to store fmx in database but..................!
    If any body knows how to store FMX in database let me know.
    Rao Guduru
    Jagadeesh (guest) wrote:
    : Hi friends,
    : How to store the forms and reports in database?
    : when i save a form in database it doesnt prompt with any
    message
    : and when i try to retrieve from the list it prompts me with a
    : message
    : can anyone suggest me the methods of storing the forms in the
    : database and retriving from it.
    : Jagadeesh
    null

  • How to store and retrieve images from database...

    Hi All
    Anubody tell me plz how to store images in database using jsp.
    and how to retrieve tme.
    Plz reply...
    Anurag

    Exactly
    try the links below may be those might help u in store and retrieval any kind of file.
    http://www.mysqltalk.org/insert-blob-example-vt112861.html
    https://java.sun.com/j2se/1.5.0/docs/guide/jdbc/blob.html
    http://javaalmanac.com/egs/java.sql/GetBlob.html
    http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.jdbc.doc/jdbc142.htm
    and a dearly advice friend please query google b4 you post any query out here.

  • How to store image in the oracle database 10.2.

    Hi.,
    I am working on 10g ids. I have designed a form where there are two fields. Name and picture.
    I want to keep details of the person with their photo.
    I can simply put name but how to insert image in the picture field??
    can you suggest ??
    Thanks.
    Shyam

    Hi
    To store your binary images in an Oracle database, you will need to create a column in your table defined with the BLOB datatype BLOB stands for Binary Large Object. Images from scanners, mpeg files, movie files and so on can all be stored in the BLOB column
    sq>CREATE TABLE test_table (
       id NUMBER,
       image BLOB);then go to
    [http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10796/toc.htm]

  • How to store photo images in a database table?

    Hello Y'all,
    How do I store about 695 signs inventory photo images from a PDF file to an Oracle database table? We are using Oracle 10.2.0.2. What data type should I use for these images? How about the table space? What table space should I allocate to ensure there is no space issue?
    Thanks in advance for any/all the help.

    Here you go..
    Assuming you have a table
    test_blob (col1 BLOB);
    Create an oracle directory or use an existing one to place the image on the oracle server.
    create or replace directory tmp_blob as '/tmp';This tmp location should exist on your server where oracle is installed.
    also ftp the image file (say image1.bmp) to this location
    declare
    l_blob BLOB;
    l_bfle BFILE;
    l_re BOOLEAN := FALSE;
    Begin
    DBMS_LOB.createtemporary(l_blob, TRUE);
    insert into test_blob(col1) values (EMPTY_BLOB())
    returning col1 into l_blob;
    --return image into l_blob;
    l_bfile := BFILENAME('TMP_BLOB','image1.bmp');
    --check if file exists
    l_ret := DBMS_LOB.fileexists (l_bfile) = 1;
    if (l_ret)
    then
    DBMS_LOB.fileopen(l_bfile);
    DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
    commit;
    else
    DBMS_OUTPUT.put_line('File not present');
    end if;
    end;
    / not tested this exact one.. check for the syntax errors if any.. this should work

  • How to store java objects in the database

    Hi,
    I am trying to store HttpSession state across Application Servers. Basically I am trying to build a sort of application cluster server on my own. I thought the best way to do this was to periodically store the HttpSession object from an application server in a database.
    I created a table in Oracle 8i with a blob column. I use a PreparedStatement.setObject() method to store the HttpSession object in the database. My problem is, I don't know how to get the object back from the database.
    Since ResultSet.getBlob returns the Blob locator, I need to read the BinaryInputStream to get all my data back. This tells me that getBlob basically works only for things like files, and cannot be used for Java objects.
    Is there any way around this? Your input would be much appreciated.
    Regards,
    Somaiah.

    Thanks for the quick reply vramakanth.
    Do I have to use a type map if I do this? Also does such a type map exist for the HttpSession class?
    Thanks,
    Somaiah.

  • How to store Video file in Oracle9i database

    Hi
    I am working on Oracle9i Database.
    I am using Oracle9i Forms Developer for front end side.
    I want to Store a video file in a database table.
    I know that there are some data types like BLOB which support such activities but actually i dont know the exact steps of doing this task.
    Can anyone guide me in this regard that from where i have to start and how to perform this activity.
    Regards
    Ikhlaq Ahmed Khan

    Please refer to this link:
    http://www.dba-oracle.com/t_storing_insert_photo_pictures_tables.htm
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to store the image in CRM database

    Hi,
    We have requirement for storing the image in the database. User can brwse for image and store it to the database and shoud retrive it for display.
    Please need help , how to do this.
    Thanks,
    Sushant

    Hi
    I hope these links will help:
    http://help.sap.com/saphelp_crm60/helpdata/de/43/a996152ce41bbde10000000a1553f7/frameset.htm
    http://help.sap.com/saphelp_crm60/helpdata/de/36/844c5cb496dc428344d3ea4c46d3b0/frameset.htm
    RP

  • How APEX stores CSS files in a database?

    We are trying to locate the tables in a database, where APEX stores the CSS Aplications files?
    We have lost some important CSS and Java Script files and we have a backup of these files. However we can not locate the table in a database, where we have to upload these backup? There is too many files to install them manually. Please help!
    Thank you for your expert consideration!

    Hi,
    uploaded files are stored in the wwv_flow_files table as BLOB.
    Try select * from wwv_flow_files.
    As they are stored in the database, you can't find them in the hard disk drive.
    As far as I know they can only be viewed in Shared Components > Cascading Style Sheets (for CSS files).

  • How to store context data into a database table?

    Hi All,
      I am very new to Web Dynpro ABAP.
    I am trying to store context data into database table. For this i need to write some code.
    I have created one context attribute to store data and i have one database table.
    Know i want to store that context attribute's data into database table.
    Can anyone provide me necessary code to do this.
    Thanks in Advance!
    Regards,
    Sreelakshmi.

    Hello Sreelakshmi,
    i think there would be some button and when u click that, the data of the context need to get saved into the database.
    For the button,create an action.
    in the action handler write the following code.
    DATA lo_nd_kna1 TYPE REF TO if_wd_context_node.
    DATA lo_el_kna1 TYPE REF TO if_wd_context_element,
    DATA lt_kna1 TYPE wd_this->elements_znode.
    DATA ls_kna1 TYPE wd_this->element_znode.
    lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_znode ).
    lo_el_kna1 = lo_nd_kna1->get_element(  ).
      lo_el_kna1->get_static_attributes( IMPORTING static_attributes = ls_kna1 ).
    modify kna1 from ls_kna1.
    Regards
    Sajid

  • How to store text file in MySql database

    Hello Sir/Madam,
    I want to store and retreive text file in mysql database ,Please give some ideas and send me code examples.

    We keep ideas and examples of this issue here:
    http://www.google.com/search?q=mysql+jdbc+clob

  • How to store a file in a database

    Is there an easy way to "put" a file (not just the path to it, but the binary data of it...) in a database ?
    In other words, do exist any classes to handle a file just like a multipart attachment ?
    And then, in which kind of database data type is better to put the file ?
    thank you in advance,
    Andrea

    ok i used this code:
    InputStream is = results.getBinaryStream("blobfile");
    FileOutputStream fileOutStream = new FileOutputStream("c:\\glasses.jpg");
    byte[] buffer = new byte[10];
    int nbytes = 0;
    while ((nbytes = is.read(buffer))!= -1)
    fileOutStream.write(buffer,0,nbytes);
    fileOutStream.flush();
    fileOutStream.close();
    is.close();
    [\code]
    where results is my ResultSet
    hope that help                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for