Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

On a Linux machine, I run a java application that accesses a SQL Server instance on a Windows machine. When I run this application I get the below error:

07-Dec-2012 15:09:40 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
[org/springframework/jdbc/support/sql-error-codes.xml]
07-Dec-2012 15:09:41 org.springframework.jdbc.support.SQLErrorCodesFactory <init>
INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak'. Operating system error 3(failed to retrieve text for this error. Reason: 15105).
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:111)
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:406)

....
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak'. Operating system error 3(failed to retrieve text for this error. Reason: 15105).
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:775)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:676)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4615)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:649)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395)
    ... 7 more

If I run the exact same application from my local Windows machine it works fine.

Any ideas why it fails when I run the application from Linux?

share|improve this question

closed as too localized by JNK Dec 10 '12 at 13:09

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Some more details will help here.. What application? What are your trying to do? What is the application trying to do? From the error message above, it looks like an issue on the SQL Server side. It looks like you are either trying to backup a database or restore a database and the path you are using for your backup file isn't being seen as valid by the machine SQL is running on. Either a permissions issue or the path doesn't exist.. –  Mike Walsh Dec 10 '12 at 12:05
    
This is the relevant portion I was referring to - your actual error, I believe Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak'. Operating system error 3(failed to retrieve text for this error. Reason: 15105). –  Mike Walsh Dec 10 '12 at 12:06
    
I am trying to restore a database called 'mydbbak.bak' which is located on the same machine that is running the MSSQL server. On the linux machine I mount the baks location with //dbs.com/data /media/baks cifs guest,uid=10 –  u123 Dec 10 '12 at 12:15
    
So if you go to the Windows machine - this path and file exist and are accessible to the SQL Server service? C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak ? –  Mike Walsh Dec 10 '12 at 12:26
1  
Ah I accidentially passed the linux path (it should only be used when looking up avaliable baks). I now pass the windows url and it works. –  u123 Dec 10 '12 at 12:43

1 Answer 1

up vote 1 down vote accepted

So the issue here is a path issue as you see in the comments on the question. There was an issue with the path being used in the restore script that u123 was using. The path was not correctly typed and this led to the error as there was no file there. This is a case of the error message being quite useful but missing some helpful text (namely - the actual error message from windows)

To understand the troubleshooting approach that I used here to investigate this one:

1.) Find the error message(s).. In this case:

Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak'. Operating system error 3(failed to retrieve text for this error. Reason: 15105)

2.) So a restore is being attempted and it is failing because the backup device can't be opened. SQL didn't retrieve the text of the windows error message, but we still have the windows error ID.

3.) I happen to know that the windows error 3 is a path issue. But if you didn't know that you can open up a command prompt and type NET HELPMSG 3 this shows us the OS error for 3.. In our case: The system cannot find the path specified.

4.) It is obviously a case where the path is invalid. The path isn't right, so double check the path and the issue should be resolved, as the OP discovered through the comments.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.