• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question for Rudy

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Rudy,
have a question
public void switchMode()
{
DataClient data = null;
if(localMode)
{
try
{
data = (DataClient) new Data("db.db");
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}

}
else
{
}
}
with this I need to do an explicit cast from dataclient to data
although I got it to compile i am getting null
any ideas??
Lisa
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Lisa, could it be possible that your loclMode is false, and it jumps to the else part of the if statement?
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rudy I even made it true I get the database error in the catch statement
So inside of this function I get the exception.
Thanks Lisa
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, the data object probably cannot find your db.db without the full path. I think you will get the same exception if you rename db.db to lisa.lisa.
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rudy I found the mistake but I still have to set a new instanxce for each search I dont know whats going on///
I set the instance back to null after the search each time to suggest GC..
What do you think?
Lisa
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
Can you elaborate your problem a little bit more?
Rudy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic