A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
problems with getting text from field...
Joined: Mar 08, 2006
Apr 10, 2006 19:01:00
Basically I want to pass some text from a field to be used as a log in.
Basically in my classes I have
USERNAME = "root";
tableModel = new ResultSetTableModel1( JDBC_DRIVER, DATABASE_URL, USERNAME,
PASSWORD, DEFAULT_QUERY );
and in another class I have
public ResultSetTableModel1( String driver, String url,
String username, String password, String query )
// load database driver class
Class.forName( driver );
// connect to database
connection = DriverManager.getConnection( url, username, password );
this all works fine, but obviously I am typing into the class all the url's, usernames etc.....is there a simple way that it can take that information from a textfield first?
That way I dont need String USERNAME = "root"; as the only way of logging on as someone OTHER than root is to change the code, which is not what I want
Joined: Mar 30, 2006
Apr 11, 2006 10:07:00
If the field is on a GUI, you can just call
, where component is a
reference (actually, any
, including TextFields and TextAreas).
If the field is on an HTML or
form, you need to get the value from the field name. For example, in a
, if the field name is "loginName", you would get it this way:
String login = request.getParameter("loginName");
Of course, there is much more to an application, standalone or enterprise...the rest of the infrastructure would depend on what you are doing.
I agree. Here's the link:
subject: problems with getting text from field...
Easiest way to pass a username to a class
Help with this code!
Database connectivity in struts 2
simple Sql connectivity problem
Help - - - ClassNotFoundException: com.mysql.jdbc.Driver
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015