Question

What I'm trying to do: find a way to backup a DB2 database via a JDBC command/query. Here's the command that I've tested with the DB2 command-line program:

backup database dbName to C:\backup\db2

It works just fine on the command line, but when attempting to run it in either Data Studio or through a standalone JDBC program, it fails. Here's the JDBC exception message:

SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: backup database dbName to C:/;BEGIN-OF-STATEMENT;<values>

Data Studio complains about "JOIN" being expected instead of "dbName", and a few other things. I have yet to find any helpful documentation about DB2, which is why I came here.

Has anyone run into this before and figured out how to resolve the issue? Or is there something I've missed?

Was it helpful?

Solution

Try using the admin_cmd procedure:

CALL SYSPROC.ADMIN_CMD('backup db mydatabase to c:\backup\db2\')

This will work also through the JDBC drivers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top