Results 1 to 2 of 2
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Rep Power

    Default deleting records in a db

    i am trying to delete all records locally on my db. here is my code:

    Java Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    public class DeleteAllDBRecords {
    	public static void main(String[] args) {
    		try {
    			String dataSourceName = "first test";
    			String dbUrl = "jdbc:odbc:" + dataSourceName;
    			Connection con = DriverManager.getConnection(dbUrl, "", "");
    			Statement s = con.createStatement();
    			s.execute("DELETE * FROM members");
    		} catch (Exception e) {
    I get this error: java.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.5.17]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM members' at line 1

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power

    Default Re: deleting records in a db

    See the following link for the proper syntax of an SQL delete statement
    SQL DELETE Statement
    Note the lack of a wildcard in the examples

Similar Threads

  1. Throttling records
    By jitman in forum New To Java
    Replies: 0
    Last Post: 03-11-2010, 07:18 PM
  2. Moving records from one Arraylist to another?
    By JavaStudent23 in forum New To Java
    Replies: 4
    Last Post: 02-17-2010, 10:52 PM
  3. insert records
    By rudravaram in forum JDBC
    Replies: 3
    Last Post: 01-03-2010, 06:54 PM
  4. How to delete the records
    By kiran kumar in forum Java Servlet
    Replies: 6
    Last Post: 11-09-2008, 02:16 PM
  5. Replies: 0
    Last Post: 02-09-2008, 09:31 PM

Posting Permissions

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