File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes java.sql.SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "java.sql.SQLException" Watch "java.sql.SQLException" New topic


Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 265
Hello Ranchers
I'm not able to update the database
i don't know why it is showing the error like this

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

here is the code below

<title>Updating User information

<%@ page language="java" session="true" import="java.sql.*" %>


String name = request.getParameter("name");
String toupd = request.getParameter("name1");
String desig = request.getParameter("desig");
String comp = request.getParameter("comp");
String addr = request.getParameter("addr");
String ph = request.getParameter("ph");
String mob = request.getParameter("mob");
String fax = request.getParameter("fax");
String email = request.getParameter("email");
String email1 = request.getParameter("email1");
String aname = request.getParameter("aname");
String amob = request.getParameter("amob");
String aemail = request.getParameter("aemail");
String plot = request.getParameter("plot");
String city = request.getParameter("city");
String place = request.getParameter("place");
String country = request.getParameter("country");
String d = request.getParameter("descr");


catch(ClassNotFoundException e)

String dbURL = "jdbc dbc:address";

Connection dbCon;

dbCon = DriverManager.getConnection(dbURL);

PreparedStatement ps = dbCon.prepareStatement("UPDATE addr SET name =?,desig=?,comp=?,plot=? ,city=? ,place=? ,country=? ,ph=? ,mob=? ,fax=? ,email=? ,email1=? ,aname=?, aemail=? ,amob=?, d=? where name="+"'"+toupd+"'");

ps.setString(1, name);
ps.setString(2, desig);
ps.setString(3, comp);
ps.setString(4, plot);
ps.setString(5, city);
ps.setString(6, place);
ps.setString(7, country);
ps.setString(8, ph);
ps.setString(9, mob);
ps.setString(10, fax);
ps.setString(11, email);
ps.setString(12, email1);
ps.setString(13, aname);
ps.setString(14, amob);
ps.setString(15, aemail);
//ps.setString(16, relation);
ps.setString(16, d);
int x = ps.executeUpdate();

out.println("Updated Successfully");
catch(SQLException e)
{out.println("address book error" +e);




any one please help me..


Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
Hey check the Database and see if there is write permissions for that Database.
For writing into .mdb, u need to have write permissions for that database.
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 265
It is not write protected..

i can insert datas in to the table..
i can read
but i cannot update..

i think the program is correct

is any other problem is this
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
Check if the readOnly property is set in your DSN.
try placing this tag in ur code.

Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
I'd try just using ps.execute() instead of ps.executeUpdate() and see what happens. Another thing to try is to introduce another bind item for:

just in case that string concatenation is something causing you to end up with something unparseable.
[ February 15, 2006: Message edited by: Reid M. Pinchback ]

Reid - SCJP2 (April 2002)
I agree. Here's the link:
subject: java.sql.SQLException
It's not a secret anymore!