Results 1 to 17 of 17
- 08-13-2010, 12:17 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
The outer loop doesnt stop running
if (userid.getText().equalsIgnoreCase("")) {
JOptionPane.showMessageDialog(null, "Type in your user id please!!");
userid.requestFocus();
} else {
try {
ps = connection.connection.prepareStatement("SELECT u.user_code, r.user_code FROM usr_pln_rghts r,users u");
String user = "";
ResultSet rs = ps.executeQuery();
while (rs.next()) {
x = userid.getText();
user = rs.getString("user_code");
usr = user.trim();
if (x.equals(usr)) {
ps = connection.connection.prepareStatement("Select U.user_code , P.plan_code , P.pln_prd_TCDE , U.PLN_BOT_LVL , U.DIM_CODE FROM PLAN_DETAIL P,USR_PLN_RGHTS U ");
ResultSet rec = ps.executeQuery();
while (rec.next()) {
String usercd = rec.getString("user_code");
String plancd = rec.getString("plan_code");
String plnprd = rec.getString("pln_prd_TCDE");
String plnbotlvl = rec.getString("PLN_BOT_LVL");
String dimcode = rec.getString("DIM_CODE");
model.addElement(usercd);
model.addElement(plancd);
model.addElement(plnprd);
model.addElement(plnbotlvl);
model.addElement(dimcode);
chooseplannameCmb.addItem(plancd);
queryResltList.add(usercd +";"+ plancd+";" + plnprd+";" + plnbotlvl+";" + dimcode);
}
connection.connection.close();
ps.close();
}
}
} catch (SQLException ex) {
Logger.getLogger(userAccessUI.class.getName()).log (Level.SEVERE, null, ex);
}
}
- 08-13-2010, 12:19 PM #2
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
i dont know what i did wrong in this code about. i need help plz
- 08-13-2010, 01:46 PM #3
Have you tried debugging the code by printing out the variables to see what is being read at each place in the loop?
- 08-19-2010, 10:36 AM #4
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
oh the problem was that there were lot of records in the database that means it was still reading those records and after sometime it does stop.
- 08-19-2010, 10:52 AM #5
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
Trasfer all items from one List to another
List queryResltList = new List();
List actionListList= new List();
//i can transfer one item :
//transfering from queryResltList to actionListList.
but now i want all items to be moved from one List to another by clicking the button.
if (e.getSource()==Btnname)
{
queryResltList.add(actionListList.getSelectedItem( ));
actionListList.remove(actionListList.getSelectedIn dex());
}
else if(e.getSource==Btnname)
{
// i need help here to transfer all items without selection.
}Last edited by Bulelakes; 08-19-2010 at 02:57 PM. Reason: i used the wrong statement
- 08-19-2010, 01:45 PM #6
A problem with your code as shown is the getSource() method returns a reference to the object sensing the event.
If your button were defined as follows:
Button buttonLabel = new Button(" a butn");
Then getSource would return a reference to the object pointed to by buttonLabel when the button was clicked.
e.getSource() == buttonLabel // the same values
This can be used in an actionPerformed method to determine which button was pressed.
- 08-19-2010, 01:53 PM #7
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
Norm
I need to know how to transfer all items from one List to another
i need the else if code leave the first if statement.
- 08-19-2010, 01:58 PM #8
Does your first "if" statement work?
- 08-19-2010, 02:12 PM #9
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
Yes indeed but im using statement like this
Btnname is a button name
if (e.getSource()==Btnname)
{
}
- 08-19-2010, 02:16 PM #10
That's not what you posted???if (e.getSource()==">")
{
Wastes everyones time posting code that you are NOT using.
- 08-19-2010, 02:24 PM #11
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
im sorry i thought that was gona do the same thing
so can u plz help me with the second "if" statement.
- 08-19-2010, 03:15 PM #12
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
my user interface looks like this
- 08-19-2010, 03:42 PM #13
Copy the code to the forum putting it inside of code tags to preserve the formatting.
- 08-20-2010, 08:20 AM #14
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
:confused:here is my code below:
XML Code://get the user code from the user and compare it with the one in database if (userid.getText().equalsIgnoreCase("")) { JOptionPane.showMessageDialog(null, "Type in your user id please!!"); userid.requestFocus(); } else { try { reslts ="SELECT u.user_code, r.user_code FROM usr_pln_rghts r,users u"; String user = ""; rs = statement.executeQuery(reslts); while (rs.next()) { x = userid.getText(); user = rs.getString("user_code"); usr = user.trim(); String usrcode= x.trim(); //if the user code matches the one in database display data where usercode is equal to the one entered by the user if (x.equals(usr)) { userids = "select user_code , plan_code,pln_bot_lvl, dim_code from usr_pln_rghts "+ " where user_code ="+"'"+usrcode+"'"; rec = statement.executeQuery(userids); while (rec.next()) { String usercd = rec.getString("user_code"); String plancd = rec.getString("plan_code"); String plnbotlvl = rec.getString("PLN_BOT_LVL"); String dimcode = rec.getString("DIM_CODE"); model.addElement(usercd); model.addElement(plancd); model.addElement(plnbotlvl); model.addElement(dimcode); chooseplannameCmb.addItem(plancd); //display the the details in queryResultList. queryResltList.add(usercd + ";" + plancd + ";"+ plnbotlvl + ";" + dimcode); } } //move selected item from queryResultList to actionListList if (e.getSource()==cpyrytBtn) { queryResltList.add(actionListList.getSelectedItem()); actionListList.remove(actionListList.getSelectedIndex()); } //move all items from queryList to actionList if (e.getSource()==cpyallrytBtn) { // i need this code here please!! //i need the statement to copy all items }
- 08-20-2010, 01:18 PM #15
The code you've posted looks like random bits and pieces copied from your program that left out a lot of things.
For example where are the variables: e, queryResltList, actionListList defined?
Where is the "outer loop that doesn't stop running?
A comment asks: //i need the statement to copy all items
Copy from where to where?
- 08-21-2010, 06:50 PM #16
- 08-23-2010, 09:42 AM #17
Member
- Join Date
- Jul 2010
- Posts
- 32
- Rep Power
- 0
Thank u so much for trying to help me ,finally i got it working below is my code:
Java Code:int i =actionListList.getSelectedIndex(); String items[]; while(i==-1) { items =(String[]) actionListList.getItems(); for(int j=0;j<items.length;j++){ queryResltList.add(items[j]); actionListList.removeAll(); } break; }
Similar Threads
-
Use stop button to stop moving (stop timers) on JPanel
By mneskovic in forum New To JavaReplies: 3Last Post: 07-23-2010, 12:50 PM -
Sax XML parse - printing outer not inner nodes
By Fliz in forum XMLReplies: 3Last Post: 01-29-2010, 08:05 AM -
How do I stop or kill a running thread when a condition is true
By chikaman in forum Threads and SynchronizationReplies: 3Last Post: 12-21-2009, 11:07 PM -
Infinite running loop problems
By BigDummy in forum New To JavaReplies: 5Last Post: 10-14-2009, 06:39 AM -
How to stop/pause running third party exe?
By 2bGeek in forum AWT / SwingReplies: 3Last Post: 02-28-2009, 07:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks