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.....
# 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)
# 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.