I have DDBB with a table Gives it, i.e. aName = "John": OK, so I want to prepare it, because of this I The function has been created: As you can see, the function returns the string [] [], so I check in the previous function if the return is not empty: and this function is a call from the listener for the pocket button: As you can imagine, JDialog is with JComboBox with all the users listed below. AUTO_INCREMENT like table But, the problem is that whenever I take an item from JComboBox, and I Any thoughts? Thank you. replaced ; Single quotes are automatically added by user and I want to get the field
user_id Trying to search for
user_name and
user_pass . Therefore, when I run the following query:
Select 'user_id`, from' user_pass` to 'user' where 'user_name` is like'% aName% ';
+ --------- + ------- - --- + | User_id | User_pass | + --------- + ----------- + | 5 | "1234" | + --------- + ----------- +
private end string QUERY_GETUSERNAME2 = "select user_id`,` user_fname` "'user'" + "WHERE like 'user_fname` ?;"; Private string [] [] getUsersInv (string usrame) {ArrayList & lt; String []> AlAux = new ArrayList (); String [] [] rate = null; Try {PreparedStatement st = _conn.prepareStatement (QUERY_GETUSERNAME2); St.setString (1, "'%" + usrName + "%'"); Results set rs = st.executeQuery (); While (rsnext ()) {string [] asAux = {String.valueOf (rs.getInt (1)), rsgetString (2)}; AlAux.add (asAux); } // while} cache (eclipse e) {e.printStackTrace (System.out); } Finally {if (! AlAux.isEmpty ()) {ret = new string [alAux.size ()] [alAux.get (0). Length]; For (int i = 0; i & lt; alAux.size (); i ++) rate [i] = alAux.get (i); } // fi} return strike; }
Public Zero Entry Inputs Invalel Modell (JetTable Table, String User) {Default Teleble Model Model = (Default Table Model) Table.GetModel (); String [] [] line = getUsersInv (user); If (line! = Null) model AddRow (line); }
Private Zero addUserActionPerformed (java.awt.event.ActionEvent evt) {if (ComboUsers .getSelectedIndex ()! = 0) {New Users (_conn) .insertUsersInvTableModel (_target, String.valueOf (comboUsers.getSelectedItem ())); _target.validate (); _target.repaint (); SetVisible (wrong); }}
user , there will be some interval (or may be) in
user_id , and the only way to build JComboBox without
user_id JComboBox For the index.
user_id and
user_pass based on the selected item (and not Same index), ResultSet is always tap.
st.setString (1, "'%' ' + UsrName + "% '");
st.setString (1, "%" + usrName + "%") with
created locations with quotation marks
% usrname% instead of the string
'% usrname%'
No comments:
Post a Comment