I have a database connection which works well when using static final Strings, i.e. DATABASE_NAME = "test";

I want to make this a little more dynamic so I created a text box on my JFrame

Code:
		txtDBName = new JTextField();
		txtDBName.setText("");
Then I created a method to return the String of txtDBName as follows:

Code:
    public String getDatabaseName() 
    { 
          return txtDBName.getText().trim(); 
    }
I then want to use the value in txtDBName as the name of my database in my connection string as follows:

Code:
conn=DriverManager.getConnection(dbView.DATABASE_URL + dbView.getDatabaseName() , username, password);
I also tried the following without any luck

Code:
conn=DriverManager.getConnection(dbView.DATABASE_URL + dbView.txtDBName.getText(), username, password);
but I keep getting a nullPointerException

Can someone shed some light on this for me?

Thanks