aspose file tools*
The moose likes JDBC and the fly likes facing problem in taking SQL Server 2005 database backup--regarding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "facing problem in taking SQL Server 2005 database backup--regarding" Watch "facing problem in taking SQL Server 2005 database backup--regarding" New topic
Author

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

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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();


Abhishek
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

DDL is non-transactional. Do as the error message tells you and run it outside a transaction.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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 ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
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!!!


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: facing problem in taking SQL Server 2005 database backup--regarding
 
Similar Threads
Having a web application in my cmpnys domain but its backup size is increasing impacting the perform
Convertion of xml file to sql file.
help
Clean database
can some one tell me what to do?