• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DDL is non-transactional. Do as the error message tells you and run it outside a transaction.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic