If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Restore Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-08-04, 10:44
tvdm tvdm is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
Restore Error

I wonder if someone could help me with 'sqlurestore' available in the DB/2 Administrative API? Below is the 'C' code I have written which is compiled into a Windows DLL and called from Java code using JNI. The code is similar to the sample available in \SQLLIB\samples\c\backrest.c. The backup works fine, but when I try to restore the database, the 'sqlca' structure returns with an error code = -1022. This error code appears to me that there is insufficient memory. I have even tried closing all applications, re-booting the machine and checking the memory. There is definitely enough memory.

Operating system : Windows XP Pro
Processor : P4-M 1.6GHz
RAM : 384MB


/*----------------------------------------------
* bkupdll.c - Source file for a C DLL
*----------------------------------------------*/

#include "jni.h"
#include "sqlutil.h"
#include "sqlenv.h"
#include "DbUtil.h"
#include <stdio.h>
#include <string.h>

JNIEXPORT jstring JNICALL Java_com_vdmsystems_util_backup_DbUtil_backup(JNIE nv *env, jobject obj, jstring destPath) {
const char *dbDir = (*env)->GetStringUTFChars(env, destPath, 0);

char errMsg[128];
char dbAlias[] = "TEST";
char userId[] = "DBUSER";
char password[] = "PASSWORD";
unsigned long buff_size = 16;
unsigned long num_buff = 1;
struct sqlu_tablespace_bkrst_list *tablespace_list;
struct sqlca sqlca;
struct sqlu_media_entry media_entry;
struct sqlu_media_list media_list;
char applid[SQLU_APPLID_LEN + 1];
char timestamp[SQLU_TIME_STAMP_LEN + 1];

tablespace_list = NULL;
media_list.media_type = 'L';
media_list.sessions = 1;

strcpy(media_entry.media_entry, dbDir);
media_list.target.media = &media_entry;

sqlubkp(
dbAlias,
buff_size,
SQLUB_OFFLINE,
SQLUB_FULL,
SQLUB_BACKUP,
applid,
timestamp,
num_buff,
tablespace_list,
&media_list,
userId,
password,
NULL,
0,
NULL,
1,
NULL,
NULL,
NULL,
&sqlca);

if (sqlca.sqlcode != SQL_RC_OK) {
sprintf(errMsg, "error = %d", sqlca.sqlcode);
return (*env)->NewStringUTF(env, errMsg);
}

return (*env)->NewStringUTF(env, timestamp);
}

JNIEXPORT jstring JNICALL Java_com_vdmsystems_util_backup_DbUtil_restore(JNI Env *env, jobject obj, jstring path, jstring timestamp) {
const char *dbDir = (*env)->GetStringUTFChars(env, path, 0);

const char *dbTimestamp = (*env)->GetStringUTFChars(env, timestamp, 0);
char restoreTimestamp[SQLU_TIME_STAMP_LEN + 1];

char errMsg[128];
char dbAlias[] = "TEST";
char userId[] = "DBUSER";
char password[] = "PASSWORD";
unsigned long buff_size = 1024;
unsigned long num_buff = 1;
struct sqlu_tablespace_bkrst_list *tablespace_list;
struct sqlca sqlca;
struct sqlu_media_entry media_entry;
struct sqlu_media_list media_list;
char applid[SQLU_APPLID_LEN + 1];
char *target_path;

strcpy(restoreTimestamp, dbTimestamp);

tablespace_list = NULL;
media_list.media_type = 'L';
media_list.sessions = 1;

strcpy(media_entry.media_entry, dbDir);
media_list.target.media = &media_entry;

sqlurestore(
dbAlias,
dbAlias,
buff_size,
SQLUD_NOROLLFWD,
SQLUD_DATALINK,
SQLUD_FULL,
SQLUD_OFFLINE,
SQLUD_NOINTERRUPT, // restore without user interaction
applid,
restoreTimestamp,
target_path,
num_buff,
NULL,
tablespace_list,
&media_list,
userId,
password,
NULL,
0,
NULL,
1,
NULL,
NULL,
NULL,
&sqlca);

// SQLUD_NOINT_WARNINGS occurs with SQLUD_NOINTERRUPT above but database still successfully restores
if ((sqlca.sqlcode != SQL_RC_OK) && (sqlca.sqlcode != SQLUD_NOINT_WARNING)) {
sprintf(errMsg, "error = %d", sqlca.sqlcode);
return (*env)->NewStringUTF(env, errMsg);
} else {
sprintf(errMsg, "");
}

return (*env)->NewStringUTF(env, errMsg);
}
Reply With Quote
  #2 (permalink)  
Old 01-08-04, 15:12
quigleyd quigleyd is offline
Registered User
 
Join Date: Nov 2002
Location: Delaware
Posts: 186
not sure about your c program, but make sure the backup buf size and restore buf size are the same and make sure that the restore is using the same amount of sessions and make sure that you have enought util_heap defined for the number of sessions that your running.
Reply With Quote
  #3 (permalink)  
Old 01-08-04, 16:47
cchattoraj cchattoraj is offline
Registered User
 
Join Date: Mar 2003
Posts: 343
quigleyd,

I have been told by IBM that the number of sessions on the backup and the restore do not need to match(and the documentation does not indicate that either). I am going to start testing tomorrow. Have you done this and know for sure that they have to match?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On