User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 422,539 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,666 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser: Programming Forums
Views: 2048 | Replies: 1
Reply
Join Date: Feb 2006
Posts: 2
Reputation: jkushner is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jkushner jkushner is offline Offline
Newbie Poster

resultset updatable

  #1  
Feb 24th, 2006
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;
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 2
Reputation: jkushner is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jkushner jkushner is offline Offline
Newbie Poster

Re: resultset updatable

  #2  
Feb 24th, 2006
Also, incase anyone was thinking that it was a lot of excessive print statements... its just for testing purposes.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Oracle Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Oracle Forum

All times are GMT -4. The time now is 12:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC