read from text file

I have written a SQL query in a text file which is like this select author, title from compinfo where price >=100; I have stored the database in Mysql and i have connected to it using jdbc. Could you provide me the code in java that would extract the query from the text file and then execute it. Please help me immediately since there is no much time.....

[366 byte] By [barkha_keni] at [2007-11-26 12:04:04]
# 1

JDBC and FileInputStream (with or without BufferedReader) or FileReader.

See the tutorials and the API doc.

Goes something like this:

open file with FileInputStream and wrap it in a BufferedReader

or

open file with FileReader

(catch errors)

readLine (catch errors)

convert read bytes/chars to String

open connection with JDBC (catch errors)

open statement using the connection and your read string (catch errors)

execute statement and receive resultSet (catch errors)

masijade at 2007-7-7 12:30:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
i am sorry to bother u but is it possible for u to provide me the code since i got no time...
barkhakeni at 2007-7-7 12:30:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
You had more than a day to wait on an answer, but no time to read?I gave you the process to use, you can cut and paste appropriate sections out of the tutorials with only slight modification using that information.Do a little searching.
masijade at 2007-7-7 12:30:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
thanx a lot for your help....did a lot of searching infact..
barkhakeni at 2007-7-7 12:30:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
U can use d following code 2 read from text fileFileInputStream fis=new FileInputStream(new File("E:\\myfile.txt"));byte b[]=new byte[fis.available()];fis.read(b);String Output=new String(b);System.out.println("File output:"+Output);
ravi@qis at 2007-7-7 12:30:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...