GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Feb-2007, 06:08
asenthil asenthil is offline
New Member
 
Join Date: Dec 2006
Posts: 24
asenthil is on a distinguished road

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

JAVA 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) {}
 }
}
}

Can anyone plzz help me....

thanks and regards..
senthil
Last edited by LuciWiz : 11-Feb-2007 at 14:04. Reason: Please insert your Java code between [java] & [/java] tags
  #2  
Old 10-Feb-2007, 16:32
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 992
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Exception: Can not issue SELECT via executeUpdate!


change this line:
JAVA Code:
stmt.executeUpdate(...
to
JAVA Code:
stmt.executeQuery(...
that worked for me. [basically, you're not performing an update, but just issuing a plain query]
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
select() fds_write and exception source code example needed draggy C Programming Language 10 24-Jun-2006 04:10
Unhandled exception gaoanyu C++ Forum 6 23-May-2006 14:48
how to issue dos command from c program jaininaveen C Programming Language 2 03-Mar-2006 11:02
C++ Copy Constructor & Exception issues greymalkin C++ Forum 3 05-Oct-2005 22:36
combo box select problem zuzupus MySQL / PHP Forum 2 23-Jul-2003 12:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:17.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.