This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to get a string return from JPasswordField?
 
Similar Threads
Java Swing
Problem with swing GUI due to lengthy code running in background.
JFCUnit findNamedComponent
BadPaddingException using AES
JPasswordField.getPassword() method