Results 1 to 2 of 2

Thread: Exception: Can not issue SELECT via executeUpdate!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    27

    Exception: Can not issue SELECT via executeUpdate!

    Hai to all,

    Now i'm trying to export Mysql table to a file By using the

    following program...

    itz sucessfully compiled... but it throws the above Exception..

    HTML Code:
    [CODE]import java.io.*;
    import java.sql.*;
    public class ExportData {
    public static void main(String args[]) {
            String Driver;
            Statement stmt; 
             ResultSet rs; 
     
             Driver = "com.mysql.jdbc.Driver";
             Connection con = null;
     
    try {
    Class.forName(Driver);
    con = DriverManager.getConnection("jdbc:mysql://192.168.0.01/senthil","root","");
     if(!con.isClosed()){
    System.out.println("Successfully connected to MySQL DataBase \n");
          stmt = con.createStatement(); 
          String filename = "C:/2.txt";
          String tablename = "employees";
          String sql;
    stmt.executeUpdate("SELECT * INTO OUTFILE \"" + filename + "\" FROM " + tablename);
      }
    } catch(Exception e) {
     System.err.println("Exception: " + e.getMessage());
        } 
    finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
     }
    }
    }[/CODE]
    Can anyone plzz help me....

    thanks and regards..
    senthil

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Exception: Can not issue SELECT via executeUpdate!

    The exception says it all. You cannot issue SELECT statements with executeUpdate(). Use executeQuery() instead.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width