wood burning stoves 2.0*
The moose likes JDBC and the fly likes Getting Problem In updating or deleting data in MS Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Getting Problem In updating or deleting data in MS Access Database" Watch "Getting Problem In updating or deleting data in MS Access Database" New topic
Author

Getting Problem In updating or deleting data in MS Access Database

Preetish Madalia
Ranch Hand

Joined: Dec 12, 2007
Posts: 37
import java.sql.Connection;
import java.util.Date;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.util.Calendar;


public class JdbcConnection {

public static final String INSERT_QUERY =
"insert into USER_SUMMARY(user_id,login_time,login_date,LOGIN_STATUS) values(?,?,?,?)";
public static final String SELECT_QUERY =
"select * from user_summary";

public static final String FIND_USER=
"select user_id from user_summary where login_status = 'Y'";

public static final String DELETE_USER_STATUS =
"DELETE user_summary.* FROM user_summary where user_id=?";



public static void main(String[] args) {

try {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ=E:/DATABASE/Database3.mdb"
);
/*System.out.println("Begining conn");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "E:/DATABASE/Database1.mdb";
String database = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";PWD=test}";
Connection conn = DriverManager.getConnection( database ,"Preetish_Madalia","preetish"); */

System.out.println("Connection Obtained : " + conn );




PreparedStatement ps3 = conn.prepareStatement(DELETE_USER_STATUS);
ps3.setInt(1,1);
int result2 = ps3.executeUpdate();
System.out.println(result2);


} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch(SQLException sqe){
sqe.printStackTrace();
System.out.println(sqe);
} catch(Exception e){
e.printStackTrace();
}


}

}


The above code runs fine. But, the problem is that the data in the table is not getting deleted.
Are there settings we need to make in order to delete/update data in tables.
Pls. look at my problem.
Thanks in advance.

Regards,
Preetish.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Problem In updating or deleting data in MS Access Database
 
Similar Threads
Invalid Handle Exception
Getting error while inserting data into table
Problem in updating/deleting data from MS Access Database
no dafault driver specified
how to connect MS Access directly