dbTalk Databases Forums  

openDatabase() throws IllegalArgumentException

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss openDatabase() throws IllegalArgumentException in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
prasadarao.kosuru@gmail.com
 
Posts: n/a

Default openDatabase() throws IllegalArgumentException - 12-01-2006 , 05:01 AM






Hi,

I am implementing a Master using BDB ReplicationManager. In this class
I'm opening a few tables using env.openDatabase() call. However when I
try to open a table which allows duplicate records, I am getting
IllegalArgumentException.

If I comment this line in the below code snippet, everything works
fine. As long as I use this line, I always get the above exception.
dbconf.setSortedDuplicates(true);

I don't know if I'm missing something.
Any help is much appreciated.

Code Snippet:

private void initDatabase(String tableName) {

Database database = null;

if( cLog.isDebugEnabled() ) cLog.debug("about create database
config for [" + tableName + "]");
DatabaseConfig dbconf = new DatabaseConfig();
// Set page size small so page allocation is cheap.
dbconf.setPageSize(512);
dbconf.setType(DatabaseType.BTREE);
if (dbenv.getIsMaster())
{
dbconf.setAllowCreate(true);
}

dbconf.setTransactional(true);
dbconf.setSortedDuplicates(true);
try
{
database = dbenv.openDatabase(null, tableName, null,
dbconf);
databasesMap.put(tableName, database);
}
catch (java.io.FileNotFoundException e)
{
cLog.warn( "[" + tableName + "] database is not
available.", e);
if (database != null)
{
try {
database.close(true);
} catch (DatabaseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
database = null;
}
try {
Thread.sleep(someinterval); //TODO ??
}
catch (InterruptedException ie) {

}
//return;
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

Many thanks inadvance,
Prasad


Reply With Quote
  #2  
Old   
prasadarao.kosuru@gmail.com
 
Posts: n/a

Default Re: openDatabase() throws IllegalArgumentException - 12-01-2006 , 06:18 AM






I figured out what's causing this exception.
It seems that, if you've an already existing database which was created
using a dbconfig object, you can't create the same database with
another dbconfig object.

If I delete the database physically from the dbhome directory the
exception goes away.
Pretty strange and misleading exception. It would have been great to
have a meaningful exception to mention the above.

On Dec 1, 11:01 am, prasadarao.kos... (AT) gmail (DOT) com wrote:
Quote:
Hi,

I am implementing a Master using BDB ReplicationManager. In this class
I'm opening a few tables using env.openDatabase() call. However when I
try to open a table which allows duplicate records, I am getting
IllegalArgumentException.

If I comment this line in the below code snippet, everything works
fine. As long as I use this line, I always get the above exception.
dbconf.setSortedDuplicates(true);

I don't know if I'm missing something.
Any help is much appreciated.

Code Snippet:

private void initDatabase(String tableName) {

Database database = null;

if( cLog.isDebugEnabled() ) cLog.debug("about create database
config for [" + tableName + "]");
DatabaseConfig dbconf = new DatabaseConfig();
// Set page size small so page allocation is cheap.
dbconf.setPageSize(512);
dbconf.setType(DatabaseType.BTREE);
if (dbenv.getIsMaster())
{
dbconf.setAllowCreate(true);
}

dbconf.setTransactional(true);
dbconf.setSortedDuplicates(true);
try
{
database = dbenv.openDatabase(null, tableName, null,
dbconf);
databasesMap.put(tableName, database);
}
catch (java.io.FileNotFoundException e)
{
cLog.warn( "[" + tableName + "] database is not
available.", e);
if (database != null)
{
try {
database.close(true);
} catch (DatabaseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
database = null;
}
try {
Thread.sleep(someinterval); //TODO ??
}
catch (InterruptedException ie) {

}
//return;
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

Many thanks inadvance,
Prasad


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.