aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how to get a string return from JPasswordField? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how to get a string return from JPasswordField?" Watch "how to get a string return from JPasswordField?" New topic
Author

how to get a string return from JPasswordField?

qionghua yang
Ranch Hand

Joined: Oct 31, 2000
Posts: 68
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

Joined: Jan 02, 2001
Posts: 783
Then you should create a String object from the char[] like this,

-Peter
qionghua yang
Ranch Hand

Joined: Oct 31, 2000
Posts: 68
Thanks a lot, peter.
qionghua
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get a string return from JPasswordField?
 
Similar Threads
Java Swing
JFCUnit findNamedComponent
Problem with swing GUI due to lengthy code running in background.
JPasswordField.getPassword() method
BadPaddingException using AES