i am interested in knowing how to make my resultset updatable. i am currently running jdk5.0 so it should already acquire such information, but the following code is throwing me errors.

public String execute( String newPassword ) throws ClassNotFoundException {


//private variables
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
String dbUrl = "jdbc:oracle:thin:hr/hr@oracle1.cise.ufl.edu:1521:orcl";
String dbUser = "jkushner";
String dbPassword = "#";
String value = "";


//first verify that they entered both a username and an email address
if ( getUsername() != null && getEmailAddress() != null)
{
System.out.println("Found user.\n");


//now we perform the db function
try
{
//make an instance of the driver
Class.forName("oracle.jdbc.driver.OracleDriver"); //create a connection
System.out.println(dbUrl + " " + dbUser + " " + dbPassword);
conn = DriverManager.getConnection( dbUrl,dbUser,dbPassword );


value = "\nConnected to database\n";


//create a statement with passed-in properties for jdbc2 updatable statements
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);


System.out.println("Resultset is now updatable");


String select = "select * from users";


System.out.println("Now executing query");


rset = stmt.executeQuery(select);


System.out.println("Performing update");


if (rset != null) {
rset.absolute(2);


System.out.println("calling updateString()");


rset.updateString("password","doifee");


rset.updateRow();
}
else {
value = "Not locatable.";
}
}


catch (SQLException e)           { e.printStackTrace(); }
catch (ClassNotFoundException e) { e.printStackTrace(); }
finally {
if (rset != null) { try { rset.close(); } catch(SQLException e) {} }
if (stmt != null) { try { stmt.close(); } catch(SQLException e) {} }
if (conn != null) { try { conn.close(); } catch(SQLException e) {} }
}
}


//input was not correct
else {} {
//value = "The system could not log you in. Please supply the correct credentials.";
}


return value;
}

Also, incase anyone was thinking that it was a lot of excessive print statements... its just for testing purposes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.