•
•
•
•
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
![]() |
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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;
}
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;
}
![]() |
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Type mismatch: cannot convert from int to ResultSet (JSP)
- ResultSet.... getterMethod() (Java)
- How in PHP get ResultSet of PostGreSql-function? (PHP)
- Java JDBC ResultSet (Java)
Other Threads in the Oracle Forum
- Previous Thread: Difficulties of build an web-based application on Oracle XML DB
- Next Thread: i need help to select command


Linear Mode