db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <florianf...@compuserve.de>
Subject Re: java escape character save retrieve problem
Date Wed, 23 Jun 2004 06:22:16 GMT
Good Morning Sandeep!

Don't know if I did understand you right. You say:
Saving a String with slashes works correct, but retrieving such rows
doesn't work?
Please send a code snippet! Would interest me since we have to do this,
too!
Is it something like: 
<example>

void save() {
  FileObject f = new FileObject();
  f.setPath("C:\\dev\\test\\myfile.doc");
  try {
    f.save();
  } catch (Exception e) {
  }
}

FileObject load() {
  Criteria criteria = new Criteria();
  criteria.add(FileObjectPeer.PATH, "C:\\dev\\test\\myfile.doc");
  try {
    FileObject f;
    List hits = FileObjectPeer.doSelect(criteria);
    if (hits.size() == 0) {
      f = null;
    } else {
      f = (FileObject) hits.get(0);
    }
    return f;
  } catch (Exception e) {
    return null;
  }
}

</example>

??? Please send your code!

F. Fray



----- Originalnachricht -----
Von: "Sandeep S. Chhikara" <schhikara@inventes.com>
Datum: Dienstag, 22. Juni 2004 10:53 pm
Betreff: java escape character save retrieve problem

> Good Afternoon Everyone, 
> 
> I am using torque 3.1 and experiencing a strange problem with 
> escape character in dir path.
> Environment:
> jdk1.4
> torque 3.1
> MSSQlServer 2000
> OS: windows 2000 server
> 
> In database table, i have a column to store filePath.
> I read a file path from file which is "SINGLE \" 
> C:\dev\test\myfile.docand since java adds a escape"\" character so 
> in debugging i see this path as " DOUBLE \\" 
C:\\dev\\test\\myfile.doc
> but while saving in DB torque saves this correctly,as expected 
> "SINGLE \" C:\\dev\\test\\myfile.doc.
> 
> When i try to retrieve this data using torque criteria the 
> filePath set as  "SINGLE \" C:\dev\test\myfile.doc
> and as discussed earlier java adds escape character torque 
> criteria has filePath value " DOUBLE \\" C:\\dev\\test\\myfile.doc.
> 
> Now i never get the saved row back, since db value  "SINGLE \" 
> C:\dev\test\myfile.doc will never match with 
>  DOUBLE \\" C:\\dev\\test\\myfile.doc and hence no row is 
> returned back.
> 
> The above mentioned example works fine with path as 
> C:/dev/test/myfile.doc ie saving and retrieval works.
> 
> Please suggest how can i fix this problem, and make torque save 
> and retrieve same value.
> 
> 
> thanks
> Sandeep Chhikara


Mime
View raw message