This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

facing problem in taking SQL Server 2005 database backup--regarding

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam getting the following exception
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot perform a backup or restore operation within a transaction.

Query:
String backupQuery="BACKUP DATABASE jiffy TO disk=?";

Iam using hibernate for database transactions:

tx =session.beginTransaction();


SQLQuery selectQuery=session.createSQLQuery(backupQuery);
selectQuery.setString(0, path);
selectQuery.executeUpdate();

tx.commit();
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DDL is non-transactional. Do as the error message tells you and run it outside a transaction.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception says, it can't perform backup operation in transaction, so had you tried removing the "transaction" specific statement, like beginTransaction and commit and re running ?
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The problem is that your code opens a transaction and then

try to execute the backup command. See the error message. You need to make the jdbc API not open a

transaction for you. How you do that, I don't know, it would be a jdbc issue, Perhaps in the

connection string, perhaps by using some other function calls in jdbc.

Cheers!!!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!