Unable to update record in java
- From: Ifloat@xxxxxxxxx
- Date: 24 Nov 2005 06:45:35 -0800
I am unable to update a record using sql statement in java. The
variable numUpdated returns 0, so I think something is wrong with my
code. The objective on thiis numUpdated variable was to return the
number of rows changed. Please help!
Code
------------------------------------------------------------------------------------------------------------------------------------
import java.sql.*;
public class simpleConn
{
Connection con;
Statement s;
ResultSet rs;
public simpleConn()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "Students.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver
(*.mdb)}; DBQ=" +
filename.trim() + ";DriverID=22; READONLY=false}";
con = DriverManager.getConnection(database, "", "");
s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.execute("select * from tStudents");
String strUpdate = "Update tStudents set Name = 'Mark', Course =
'IELTS' where No = 15";
int numUpdated = s.executeUpdate(strUpdate);
System.out.println("updated rows" + numUpdated);
}
catch (Exception e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
simpleConn su = new simpleConn();
}
}
--------------------------------------------------------------------------------------------------------------------------------
.
- Follow-Ups:
- Re: Unable to update record in java
- From: zhaoyh.hxtt@xxxxxxxxx
- Re: Unable to update record in java
- Prev by Date: connection ms Access to MIDlet
- Next by Date: Re: Needed: An Efficient, reliable and smart way to copy data from one DB to another
- Previous by thread: connection ms Access to MIDlet
- Next by thread: Re: Unable to update record in java
- Index(es):