| | |
help me
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
•
•
Hi I am trying get user info from the database into the textbox when i select Usename Which is stored in the drop down. so could any help how to get all usernames into dropdown and when i select any usenames i should get all details into the text box.........please elp me
write a class to connect to the db, write the code that reads the date in the db and use it.
first of all, this forum is not intended to deliver instant j2ee sollutions, and even if it was, we don't know what you are doing, whether you are using a framework, ...
make a start and come back with questions about your code, not with the classical no-no "plz write mah codez" or something of that sort
•
•
Join Date: Mar 2004
Posts: 765
Reputation:
Solved Threads: 38
This all depends entirely on where your usernames are stored. In a database? A file? Hard-coded?(better not be)
Open the Java API docs and review the contructors for JComboBox (assuming you plan to use the Swing framework) and that'll give you some ideas on how to add usernames to the drop-down list.
http://java.sun.com/docs/books/tutor.../combobox.html
Add an ActionListener to the combo box to listen for when a username is selected from the list. Then simply connect to your database and pull the information you need. JTextField.setText() will set the text of the text box.
Open the Java API docs and review the contructors for JComboBox (assuming you plan to use the Swing framework) and that'll give you some ideas on how to add usernames to the drop-down list.
http://java.sun.com/docs/books/tutor.../combobox.html
Add an ActionListener to the combo box to listen for when a username is selected from the list. Then simply connect to your database and pull the information you need. JTextField.setText() will set the text of the text box.
Last edited by Phaelax; Sep 19th, 2008 at 6:06 am.
•
•
Join Date: Sep 2008
Posts: 7
Reputation:
Solved Threads: 0
Ok thanks for your help, Actually i need to edit the user information which is stored in the mysql database, for that i need to fetch the data from database for perticular user. I have written java class in that I am storing all the usernames in an Array list. I need to display these ArrayList usernames in drop down box. I dont how to do that pls help me
•
•
Join Date: Sep 2008
Posts: 7
Reputation:
Solved Threads: 0
•
•
•
•
This all depends entirely on where your usernames are stored. In a database? A file? Hard-coded?(better not be)
Open the Java API docs and review the contructors for JComboBox (assuming you plan to use the Swing framework) and that'll give you some ideas on how to add usernames to the drop-down list.
http://java.sun.com/docs/books/tutor.../combobox.html
Add an ActionListener to the combo box to listen for when a username is selected from the list. Then simply connect to your database and pull the information you need. JTextField.setText() will set the text of the text box.
•
•
•
•
Ok thanks for your help, Actually i need to edit the user information which is stored in the mysql database, for that i need to fetch the data from database for perticular user. I have written java class in that I am storing all the usernames in an Array list. I need to display these ArrayList usernames in drop down box. I dont how to do that pls help me
There are two ways to add usernames from ArrayList to ComboBox (that i have in mind now).
One is using forloop, Get each username from ArrayList and add it to ComboBox.
and second one is, Get Array object from ArrayList using toArray() method.
JComboBox comboObj = new JComboBox(Object []usernames);
and use this constructor. This will automatically add all elements of Array into ComboBox.
Regards,
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer
Admin of Pikk - Object Relational Mapping Framework
www.PuneetK.com
Sun Certified Java Programmer
Admin of Pikk - Object Relational Mapping Framework
•
•
Join Date: Sep 2008
Posts: 7
Reputation:
Solved Threads: 0
I need to fetch the data from database by using usernames which is in drop down, for this i need to write a query such that for where condition in query i need give the username,....then that query will execute and it vl return some user data.Now the problem is whenthe user select username which is in drop down that username should be the condition in query i dont know how to use this username in my query.......some one told me to use session....is it ok shell i use session...please help me its very urgent
Next time be more clear about what is your problem. From what I understood you don't know how to get and use the username from the comboBox?
If yes assume that you have a String username variable. For getting the value from a comboBox that has String elements do this:
String username = comboBox.getSelectedItem().toString() ;
Then create in a seperate class a method that take as argument that username and calls your query
And call it with argument what you get from the comboBox.
If yes assume that you have a String username variable. For getting the value from a comboBox that has String elements do this:
String username = comboBox.getSelectedItem().toString() ;
Then create in a seperate class a method that take as argument that username and calls your query
JSP Syntax (Toggle Plain Text)
class DBManager { public void/*or whatever you want to return*/ method(String username) throws SQLException { // code here }
And call it with argument what you get from the comboBox.
JSP Syntax (Toggle Plain Text)
String username = comboBox.getSelectedItem().toString() ; DBManager dbM = new DBManager(); try { dbM.method(username); } catch (Exception e) { }
Check out my New Bike at my Public Profile at the "About Me" tab
Is this part of an application or it should be used as part of web service?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Other Threads in the JSP Forum
- Previous Thread: Form data
- Next Thread: servlet +tomcat 5.0.28+access database+problems
| Thread Tools | Search this Thread |
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






