Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Backups
»
database backup and restore in sql server...
16 posts, Page 1 of 2
1
2
»»
database backup and restore in sql server 2005
Rate Topic
Display Mode
Topic Options
Author
Message
abhishek.c1984
abhishek.c1984
Posted Wednesday, July 22, 2009 5:08 AM
Grasshopper
Group: General Forum Members
Last Login: Saturday, October 03, 2009 2:56 AM
Points: 11,
Visits: 25
Need help in taking database backup and restore using java......
Database: SQLServer 2005
I have done it this way.....
SQL Backup Query="BACKUP DATABASE mydatabase TO disk=?";
while executing, iam getting the following error ....
Cannot perform a backup or restore operation within a transaction.
Also let me know, how to make a forced database backup?
Post #757297
ALZDBA
ALZDBA
Posted Wednesday, July 22, 2009 5:28 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 2:17 AM
Points: 6,862,
Visits: 8,049
Which driver are you using ?
Are you (or the driver by default) using implicit transactions ?
A backup/restore operation cannot be incapsulated with a transaction.
If a restore fails, the db is left in its failed state (restoring) !
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #757306
Grant Fritchey
Grant Fritchey
Posted Wednesday, July 22, 2009 5:52 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 1:09 PM
Points: 13,383,
Visits: 25,187
What do you mean by a "forced" database backup?
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #757316
abhishek.c1984
abhishek.c1984
Posted Wednesday, July 22, 2009 6:31 AM
Grasshopper
Group: General Forum Members
Last Login: Saturday, October 03, 2009 2:56 AM
Points: 11,
Visits: 25
thanks for the reply.......
Iam using type 4 driver (sqljdbc) .......
If a query has to be executed, it has to be in transaction......
Or else is there any other way?
What do you mean by a "forced" database backup?
Sometimes, while executing the query i have encountered the following error
"some active connections.........."
So before going ahead, i need to close the active connections and then proceed further.......So, in such cases is it possible to make forced backup and restore...
Note: forced in the sense, complete the database operations irrespective of active connections
Post #757357
ALZDBA
ALZDBA
Posted Wednesday, July 22, 2009 6:59 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 2:17 AM
Points: 6,862,
Visits: 8,049
abhishek.c1984 (7/22/2009)
... "some active connections.........."
So before going ahead, i need to close the active connections and then proceed further.......So, in such cases is it possible to make forced backup and restore...
Note: forced in the sense, complete the database operations irrespective of active connections
Probably it refers to open connections to the target database of your restore operation.
If you want to restore with interrupting all connections,
just start your restore statement by adding
alter database yourdb set offline with rollback immediate ;
restore database ...
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #757387
Grant Fritchey
Grant Fritchey
Posted Wednesday, July 22, 2009 7:24 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 1:09 PM
Points: 13,383,
Visits: 25,187
Ah, right. ALZDBA answered it. You're not forcing the backup, you're forcing the restore, but not even that really, you're just kicking all the users off the database.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #757418
abhishek.c1984
abhishek.c1984
Posted Thursday, July 23, 2009 12:11 AM
Grasshopper
Group: General Forum Members
Last Login: Saturday, October 03, 2009 2:56 AM
Points: 11,
Visits: 25
thanks for the reply,
I have just executed the query in SQL Server 2005, it worked fine...but the database connection was broken
-------
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Failed to restart the current database. The current database is switched to master.
RESTORE DATABASE successfully processed 561 pages in 0.350 seconds (13.130 MB/sec).
---------------------
But it failed to start the current database...
Error:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset by peer: socket write error
Note: How can i use this query in the application?
It is giving the following error
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: ALTER DATABASE statement not allowed within multi-statement transaction.
Post #757985
ALZDBA
ALZDBA
Posted Thursday, July 23, 2009 1:31 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 2:17 AM
Points: 6,862,
Visits: 8,049
abhishek.c1984 (7/23/2009)
thanks for the reply,
I have just executed the query in SQL Server 2005, it worked fine...but the database connection was broken
-------
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Failed to restart the current database. The current database is switched to master.
RESTORE DATABASE successfully processed 561 pages in 0.350 seconds (13.130 MB/sec).
---------------------
But it failed to start the current database...
Error:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset by peer: socket write error
Note: How can i use this query in the application?
It is giving the following error
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: ALTER DATABASE statement not allowed within multi-statement transaction.
Don't use a transaction to perform backup or restore operations !!
( it does not have a transaction scope - there is no rollback feature for backup / restore !)
Do not connect to the database you are trying to restore !
Connect to master or tempdb to perform your database restore operation.
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #758008
abhishek.c1984
abhishek.c1984
Posted Thursday, July 23, 2009 3:14 AM
Grasshopper
Group: General Forum Members
Last Login: Saturday, October 03, 2009 2:56 AM
Points: 11,
Visits: 25
thanks for the reply.....
Can you please let me know how can i connect to master or tempdb to perform database restore operation.
Tell me how to perform this operation from the java application, without being connected to database
Post #758048
ALZDBA
ALZDBA
Posted Thursday, July 23, 2009 3:52 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 2:17 AM
Points: 6,862,
Visits: 8,049
BP is always to specify the database name you want to connect to (don't rely on the logins default database ! A sql instance can host multiple databases !)
Check out BOL for the jdbc driver:
http://msdn.microsoft.com/en-us/library/ms378988%28SQL.90%29.aspx
IMO you should provide as many info as you can in your connection !
This will help with problem solving, monitoring, ...
e.g.
// Get connection
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
String url="jdbc:microsoft:sqlserver://yourip;
DatabaseName="yourdb";
Connection conn=DriverManager.getConnection(url,"username","password");
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #758058
« Prev Topic
|
Next Topic »
16 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.