File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes java.sql.SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException" Watch "java.sql.SQLException" New topic
Author

java.sql.SQLException

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
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

<html>
<head>
<title>Updating User information
</title>
</head>

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

<body>
<%


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");

out.println(name);
out.println(toupd);



try
{
try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{out.println(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(x);
dbCon.commit();

out.println("Updated Successfully");
dbCon.close();
ps.close();
//stmt.close();
}
catch(SQLException e)
{out.println("address book error" +e);

}
%>

<br>

</body>
</html>



any one please help me..

please


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: 263
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)
 
jQuery in Action, 2nd edition
 
subject: java.sql.SQLException
 
Similar Threads
Cache Problem in Jsp...
Trouble with "@" and spaces in mySQL
creating virtual tables
JSP program error
Updating Problem