Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A small Sql Question

 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to insert data into sql database and the data comes from a file and gets transferred directly to the database. the problem is that one of my fields is to collect pathnames. now whenever the data reaches the databases the slashes are gone
for ex if the path in the datafile is like \\rhino\users\vol1\sim
then in the database it will be like \rhinousersvol1sim
one way to correct is like adding one more \ after every \ but since it going directly i can't, i was just wondering if there is a way to tell the sql to ignore the slashes
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anybody know anything about it?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of questions:
What is the database?
How is the data being transfered? You said it is automatically, how is it automated? A DTS package on SQL server, a chron job, a scheduled task?
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is a mysql datbase , basically i have this log file and it has the data in it so i wrote a java program to parse through the data file and make them into fields and then put into a mysql datatbase now one of the fields in the datat file carry a path for ex \\flag\someting\something
now when this gets transferred to a database it changes to \flagsometingsomething
so i was looking for a way to enforce sql not to ignore "\"
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sim
Check out the Strings section of the MySQL manual. The \ is an escape character so you'll have to use the \\ to get a single \ into your table. You might want to write a simple method to escape all of the single \ in your String before inserting them.
hope that helps
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks , yeah i inserted "\" by using indexof method
thanks bud
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic