This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and Relational Databases and the fly likes Savepoint in jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Savepoint in jdbc" Watch "Savepoint in jdbc" New topic

Savepoint in jdbc

Ann Sebastian
Ranch Hand

Joined: Sep 21, 2005
Posts: 37
Hi all,
I want to use savepoints to execute my functions.Functions do not have an
explicit commit statement.

On executing the folowing code snippet I get Error:

c = DriverManager.getConnection(url, username, password);
System.out.println("connection successful");

Savepoint starttrans=c.setSavepoint("CustomBusinessLogic");

//First Function
CallableStatement stmt = c.prepareCall("Begin ? := fnCreateVoucherTb(?,?,?,?,?,?,?,?); End;");
System.out.println("Executing Create Function");
stmt.setInt(2 , 1);
stmt.setString(3 , "Nu");
stmt.setString(4 , "BNumber");
stmt.setString(5 , "29-Sep-05");
stmt.setString(6 , "29-Oct-05");
stmt.setInt(7 , 3);
stmt.setInt(8 , 3);
stmt.setString(9 , "29-Sep-05");
pk = stmt.getInt(1);

//Second Function
stmt = c.prepareCall("Begin ? := fnSaveVoucherTb(?,?,?,?,?,?,?,?,?,?); End;");
stmt.setString(4 , "FirstFunction");
stmt.setString(5 , "BatchNumber1");
stmt.setString(6 , "03-OCT-05");
stmt.setString(7 , "03-OCT-05");
stmt.setInt(8 , 3);
stmt.setInt(9 , 3);
stmt.setString(10 , "03-OCT-05");
stmt.setString(11 , "2005-10-05");
System.out.println("Save Function: set the parameters");
System.out.println("Procedure Executed");

catch(SQLException e)
System.out.println("Error Occured" + e);

Error Occuredjava.sql.SQLException: ORA-01086: savepoint 'CUSTOMBUSINESSLOGIC' never established

What is the problem
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31551

Welcome to JavaRanch!

On which line of code does the code throw the exception? When you set the savepoint at the beginning or when you rollback to it?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Savepoint in jdbc