Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can you use a source sourcefile.sql command via the ODBC connector?

Status
Not open for further replies.

excession

Programmer
Sep 22, 2004
111
GB
I have a source file which creates and populates the database, I wolud like to be able to call this file from withing my application program using the ODBC connector. However when I try I just get error 1064.

My application is in java .. here is the code snippet concerned..
Code:
try {
            Statement st = con.createStatement();
            sqlquery = "source c:\\mysql\\bin\\rj_create.sql";
            rs = st.executeQuery(sqlquery);
            try {
                while (rs.next()){
                    System.out.println(rs.getString(1));
                }
                
            } catch (SQLException se) {
                System.err.println("reading SQLException: " + se.getMessage()) ;
                System.err.println(sqlquery);
            }
} catch (SQLException e){
            System.err.println("querying SQLExcpetion " + e.getMessage());
            System.err.println("err code " + e.getErrorCode());
            System.err.println(sqlquery);
}

 
The only way I know of is to read the file, and pass its contents to MySQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top