473,791 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to read multiple (binary) lines from text file / stdin?


hi group!
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.

i would like to use an input file like this:
-- file statement.sql --
select * from table
where thing = "something" ;
------------------------
or

-- file statement.sql --
update table
set image = '<binary data>'
where thing = otherthing;
------------------------

this is how the code looks so far:
// code start

BufferedReader in = new BufferedReader( new FileReader(file name));

while (((statement=in .readLine())!= null) &&(!statement.e quals(""))){
try {
ResultSet rset = stmt.executeQue ry(statement);
[...]
}
}

// code end
i would like 'statement' to contain the multiline sql statement
including all newlines so that also binary data may be inserted into the
db so i tried to use

System.setPrope rty("line.separ ator", ";");

but that didn't help and also doesn't seem the right way for what i want
to achieve. could someone please point me into the right direction on
how to do that? the variety of different stream classes is somewhat
confusing in terms of finding the right class for the right job.
big TIA, armin
--
armin walland

focusmr.com
maculangasse 8
1220 wien
Jul 17 '05 #1
2 9803
armin walland <ge******@gmx.a t> wrote in message news:<sl******* **************@ armin.focusmr.c o.at>...
hi group!
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.


Take a look at the StreamTokenizer class in java.io . It is quite
daunting for beginners, so you might want to Google around for a good
tutorial on how to use it. It is designed to parse language source
code, and has a few handy in-built features for handling comments and
string literals, etc.
-FISH- ><>
Jul 17 '05 #2
On 2004-01-27, FISH <jo*****@mersey mail.com> wrote:
armin walland <ge******@gmx.a t> wrote in message news:<sl******* **************@ armin.focusmr.c o.at>...
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.


Take a look at the StreamTokenizer class in java.io . It is quite
daunting for beginners, so you might want to Google around for a good
tutorial on how to use it. It is designed to parse language source
code, and has a few handy in-built features for handling comments and
string literals, etc.


thanx a lot :)
rgds, armin
--
armin walland

focusmr.com
maculangasse 8
1220 wien
+43 (0)1-258 97 01 291

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3066
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one single file, but then be able to take this one single file and recreate the files I put into it. Im really at a loss as to how I go about recovering the files?
3
3498
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is possible to change the behavior of operator << so it will stream numeric values as their actual values when an ofstream is in binary mode. I did not, however, find any information on how this can be accomplished. What is involved in getting this...
2
1220
by: Pramod Kumar | last post by:
Dear All, I want to read data from a text file using Stream Reader. Please tell me the .DLL file to be added for the same. Regards, Pramod
7
3061
by: bowlderster | last post by:
Hello, all. This is the text file named test.txt. 1041 1467 7334 9500 2169 7724 3478 3358 9962 7464 6705 2145 6281 8827 1961 1491 3995 3942 5827 6436 6391 6604 4902 1153 1292 4382 9421 1716 2718 2895 I wanna to read the data to an array, as the follows:
29
4890
by: list | last post by:
Hi folks, I am new to Googlegroups. I asked my questions at other forums, since now. I have an important question: I have to check files if they are binary(.bmp, .avi, .jpg) or text(.txt, .cpp, .h, .php, .html). How to check a file an find out if the file is binary or text? Thanks for your help.
2
5519
by: RyanS09 | last post by:
Hi- I have read many posts with specific applications of reading in text files into arrays, however I have not been able to successfully modify any for my application. I want to take a text file filled with a tab delimited list of 10 columns (floats) and read it into a 2D array. The length of the columns are all the same, however this will be variable from text file to text file. Any help (starter code or where to read) would be much...
4
15618
by: Chris | last post by:
I am using the FileSystemOBject for writing text with Unicode as in the example below. When I try to read data from the file with ReadLine, I get "?????????" instead of characters with unicode. What could be the problem ? Thanks a lot in advance! ------------------------------------------------------------------------------------------------
7
8084
by: voroojak | last post by:
Hi I have a text file that has differnt information to be more clear i hav eto say that i have three differnt kind of information. the column name for all the information are same but there is number at the top that i can undestand whenere shall it go. it looks like some thing like this 102 (There are some lines here that i do not need it) A B ...
6
418
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another set of integers stored in an array.It would be a great help if you could provide some code for it.I tried the function fscanf but by that I am able to read only the first integer of the text file.Please help me.
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.