dcsimg
Delete multiple rows against Ms Access doesn't work
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Francis_Perez
Posted On:   Wednesday, April 9, 2003 10:13 AM

DELETE FROM Docs WHERE Area="Fin"

When I try to execute this update through java, it doesn't work.

When I do it inside Ms Access Query Manager, i works.

Could you help me?

Very thanks!

Re: Delete multiple rows against Ms Access doesn't work

Posted By:   Pazhanikanthan_Periasamy  
Posted On:   Thursday, April 10, 2003 05:46 AM

When I used the following code, it works fine... It would be better to send us some snippet so that we can let u know what is the problem


import java.sql.*;

import java.util.*;



public class MSAccess

{

public static void main (String a []) throws Exception

{

Connection conn = null;

Statement stmt = null;

ResultSet rset = null;



final int TOTALRECORDS = 100000;



try

{

// Load Oracle driver

Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );

// Connect to the local database

conn = DriverManager.getConnection ("jdbc:odbc:Pazhani", "", "");



StringBuffer sbfBuffer = new StringBuffer ("");



sbfBuffer = new StringBuffer ("");

sbfBuffer.append ("SELECT * FROM Docs");

// Query the employee names

stmt = conn.createStatement ();

rset = stmt.executeQuery (sbfBuffer.toString ());

while (rset.next())

{

System.out.println ("The First Column is :" + rset.getInt (1));

System.out.println ("The Second Column is :" + rset.getString (2));

System.out.println ("The Third Column is :" + rset.getString (3));

}



sbfBuffer = new StringBuffer ("");

sbfBuffer.append ("DELETE FROM Docs WHERE Area='Richmond'");

// Query the employee names

stmt = conn.createStatement ();

int intReturn = stmt.executeUpdate (sbfBuffer.toString ());



}

catch(Exception expGeneral)

{

expGeneral.printStackTrace ();

}

finally

{

try

{

if (rset != null)

{

rset.close ();

}

if (stmt != null)

{

stmt.close ();

}

if (conn != null)

{

conn.close ();

}

}

catch (Exception exp)

{

}

}



}

}
About | Sitemap | Contact