Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

java.sql.SQLException

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check if the readOnly property is set in your DSN.
try placing this tag in ur code.

 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic