• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get a string return from JPasswordField?

 
qionghua yang
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using JPasswordField in my program. I would like to use this password to access to my Informix Database.
Some source code:
.....
JPasswordField password = new JPasswordField();
.....
Connection c = DriverManager.getConnection(url, userName.getText(), password.getPassword());
.....
This gives me some the compile error because the return value of getPassword is char[], and the DriverManager is expecting a String.
Anyone can help? Thanks!
qionghua

 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you should create a String object from the char[] like this,

-Peter
 
qionghua yang
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, peter.
qionghua
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic