javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

can you give me the complete code of JProgreesBar..i dont have idea in making the code please help me so that i can have idea on this..thanks in advance.

Read the API for the classes mentioned here and see what you can do.
JProgressBar.
A link with a tutorial has also been provided in a previous post. Did you find it helpful?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You get this exception:

java.net.MalformedURLException: unknown protocol: c

When you read the file. I assumed that your file could not be read dut to a tag error.

But then I see in your file this:

<INPUTFOLDER>C:\</INPUTFOLDER>

I am no expert in xml, But can you try this:
Call the command that gives you the exception in a separate main method and see if you get the same exception.:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = factory.newDocumentBuilder();
                Document doc = factory.newDocumentBuilder().parse(fileName);

If yes, change the value of C:\ with something else and see if you will get the same error

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can you post the contents of the xml file?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because bold doesn't show very good try to add some color as well next time.

Is this the line:
Document doc = factory.newDocumentBuilder().parse(fileName)

If yes the problem might be with the contents of the file.

Also I noticed this:

public boolean writeToOldFile(String str_fileName) {
        str_jobName = txt_jobName.getText();
        String str_settings = "<JOB>\n" +
                "<JOBNAME>" + str_jobName + "</JOBNAME>\n" +
                "<INPUTFOLDER>" + str_inputFolder + "</INPUTFOLDER>\n" +
                "<FILEMASK>" + str_fileMask + "</FILEMASK>\n" +
                "<PROCESSORDER>" + str_processOrder + "</PROCESSORDER>\n" +
                "<RETAINFOLDER>" + str_retainFolder + "</RETAINFOLDER>\n" +
                "<OVERRIDEFOLDER>" + str_overrideFolder + "</OVERRIDEFOLDER>\n" +
                "<ERRORFOLDER>" + str_errorFolder + "</ERRORFOLDER>\n" +
                "<POLLINTERVAL>" + str_pollInterval + "</POLLINTERVAL>\n" +
                "<JOBBATCHFILEPATH>" + str_jobBatchFilepath + "</JOBBATCHFILEPATH>\n" +
                "<JOBBATCHPARAMS>" + str_jobBatchParams + "</JOBBATCHPARAMS>\n" +
                "<JOBLOGPATH>" + str_jobLogPath + "</JOBLOGPATH>\n" +
                "<JOBEMAILTO>" + str_jobEmail + "</JOBEMAILTO>\n" +
                "<JOBALTEMAILTO>" + str_jobAltEmail + "</JOBALTEMAILTO>\n" +
                "</JOB>\n" +
                "[B]</APOLLERSETTINGS>[/B]\n";

Is it correct that you close the APOLLERSETTINGS without being open? Do you open it somewhere else?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I thought the char datatype does not support readLine

I didn't look at the API, but you are probably right.

If that is the case then you can use String:

String option="";

....
do {

  option = br.readLine();
} while(option.equals("y"));

Or you can do this:

System.out.println("Do you want to calculate anything else?(y/n)");
  option=(char)br.read();

  [B]br.readLine();[/B]

} while(option=='y');

With that extra call you leave the line where the 'y' was entered.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't read the entire code but from what I can understand, you are entering from the keyboard a value that is not a number.
I just saw that you are using:
br.read() , instead of br.readLine() when you read the 'y'/'n' input. Why?

When you call the read method, you don't "change lines" so the next time you call readLine, it will not read the next line but the rest of the current.

You enter >'y' and you use read (doesn't change line)
The next time you call readLine, the cursor is still at the line: >'y'
And reads what is after: an empty String: ""

Throughout your program you call readLine:
>123
You read the number and the next you will cal any read method it will read the next line.

But with simple read, you read the line but you don't change lines in order to read the next.

Try calling all the time the readLine.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the internet for the definition of a magic square and then post some code

Salem commented: Nice +18
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually I was thinking something like this:

public double getSqrRoot( argument ) throws ArithmeticException {
  // code
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As I said you are calling the Integer.parseInt with argument an empty String: "" , as the exception says.

So how does the argument of that method takes value? Shouldn't you put it in a try-catch block?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There are the JProgressBar, JScrollBar classes that might be usefull to you. For better results, maybe you need to put one of them in a thread. One thread will do the loading and the other will display the loading bar

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In my previous post I suggested for you to print the query and try to run it at the database in order to see if it will run. Try that, and tell me if it brought correct results.

Also search your code again in case you have something open. Remember:

// open connection, Statement, ...
//run query
// close everything in the finally

I searched the web for that error. You should have done the same.

Can you try and using this command in order to create the statement:
>> st =conn.createStatement()

Also from what I have found, can you check your code if you are using any commands like setAutoCommit() ?

If the above suggestion don't solve your problem can you post the query you used to create the table. Also the data types of the columns would be helpful.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You wrote this:

String ptNo=null;
Patient pt = getPatient(ptNo);

You passed as argument null. It is in front of your eyes!

With every error you got you didn't made a single attempt ot try and fix it. You just posted and expected others to tell you the asnwer so you can continue until you make the next error.

You got an SQLException. Did you try to print the query and run it in order to see what is executed. The above has nothing to do with java. It is common sense.

There is a difference between being a beginner in java and not being able to think for yourself. I have told you everything you need to know to fix this. If you can't put some simple code together then I am not going to write the code for you in order to get your intership.

Fix this and if you have another question that has nothing to do with this, then start a new thread and someone will answer it. I have wasted my time here.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

So for my purposes of understanding this, my error in my ways was that i was closing the stream before i had finished writing, so technically it was outputting the results correctly but only processing one line to file?

Thank you by the way javaAddict and yep i checked out your bike too in the process. You have to make sure she stays royal that one; will get a fair bit attention.

I assume that your problem has been fixed. Do you get the results that you want?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The exception tells you where the error is:
at converter.main(basic_convert.java:20)

You are calling Integer.parseInt with argument an empty String: "" As the exception says:
java.lang.NumberFormatException: For input string: ""

Try to read it first before posting this entire, unrelated piece of code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

From what I see you just copied my code blindly. You didn't even bother to understand anything. How do I know this?
For starters, the method takes as argument the patienNo, but instead of using that, you used this: "PatientNumberList.getSelectedValue()"

And when you call the method you call it with null:

String ptNo=null;
Patient pt = getPatient(ptNo);

So you need to decide, do you want an argument, or you will take the value directly with the getSelectedValue() ?


Once you get the Patient you can do whatever you want with its values. Set them to text fields, open a new JFrame and display them, ...

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Inside the for you do this:

BufferedWriter bw = new BufferedWriter(new FileWriter("audits.txt"));

String s = lines[i];
bw.write(s);
bw.flush();
bw.close();
}

Meaning that with each loop open the file, overwrite that was written and you close.

You need to open the file, write whatever you want and when you are done close it:

BufferedWriter bw = new BufferedWriter(new FileWriter("audits.txt"));

for (int i=0;i<lines.length;i++) {
  String s = lines[i];
  bw.write(s);
  bw.newLine();
}

bw.flush();
bw.close();
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

"The method readMethod() is undefined for the type Control".

It is because you haven't defined the readMethod. You can call it whatever you want. But you need to implement it. Inside it you will read the file and return the results.
You should also define a class Heat with an array of Athletes and have that return a Vector of Heats.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public Patient getPatient(int patientNo) throws SQLException {
// Connection, statement, ResultSet

// Call query

// get the info

Patient pt = new Patient();
pt.set...(..)

// close Connection, statement, ResultSet

return pt;
}

If there is no patient found, you can return null, and after you call the method you check that and print the right message:

Patient pt = null;

..

if (rs.next()) {
 pt = new Patient();  

 pt.set...(..)
}

return pt;
Patient pt = getPatienNifo(ptNo);
if (pt==null) {
  // show message 
} else {
  use the pt values to set them wherever you want
}

If you want it to be added to a JTable check the setModel method of the JTable class. You will use a DefaultTableModel instance. Check the API and you will find methods that can help you.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Of course it doesn't print anything because you have things inside the if. And the if statement return false.
Every time you run that code the numberOfAttempts is initialized to zero. So it will never reach 3. This is not where you need to declare it.
You should add a "System.out.println" before the if to see what is the variable's value. Try to do that every time you are stuck.
Its value shouldn't be initialized to zero every time you run the code, that is why I didn't declare anywhere near that code.
It should be declared somewhere where its value isn't set to zero every time you try to log in. Perhaps as a global variable.


If you can't understand that, then you need to study more and don't do so complex things. There is nothing more I can explain on this matter. Everything you need so you can fix it, have been told.

You asked me why you don't see the message, when the if statement is right there in front of you, you wrote it. Don't you know what if statement do? Did I have to tell you that the code inside the if doesn't execute because the if is false?

If you have any more questions on something else then I will answer them. But these things are not for beginners as you mentioned.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Scanner scn = new Scanner(System.in);
int i = 0;

if (scn.hasNextInt()) 
  i = scn.nextInt();

That is for reading from keyboard. Read the first number and assume that it is the max:

Scanner scn = new Scanner(System.in);
int num = 0;
int max = 0;

  num  = scn.nextInt();

max = num ;

Then read the rest of the numbers,but, Every time you read a number compare it with "max". If that "number" is greater than "max", it means the new number is the largest so replace the old value of "max" with the new:

if (number>max) {
  max = number;
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I cannot help if you don't follow my suggestions. This is what I wrote:

if (rs.next()) {
} else {
 [B]numberOfAttempts++;
 if (numberOfAttempts>3) {
   // Attempted to log unsuccessfully for 3 times
 }[/B]
}

And you wrote:

if(rs.next()){
                }
                else{
                    [B]int numberOfAttempts=0;
                    while(numberOfAttempts<=3) {
                    JOptionPane.showMessageDialog(null, "Login failed, try Again");[/B]
                    }
                    [B]numberOfAttempts++ ;
                     if (numberOfAttempts>3) {
                     System.exit(1);
                     }  [/B]             
              }

The while loop will always be true:

int numberOfAttempts=0;
while(numberOfAttempts<=3)

So it will never end. The idea is whenever you don't enter correct username, password to increase a counter. If the counter becomes greater than 3, (3 unsuccessful attempts) exit the application.
And you went and declared it in the else { .. }. Meaning that it will always be 0 and will never reach 3.
Can't you imagine where it should have been declared or you didn't think that upon successful log in to initialize it back to 0?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have never tried that before but you can do this and see if it works:

Instead of sending the value of the combo box have 2 hidden fields:

<input type="hidden" name="hiddenList1" value="" />

When you click the button to submit run a javascript that loops the list and appends its values to the hidden field. Then when you get the request, you can use the split() method to separate the values.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use the method of JTable: setModel(TableModel dataModel).
Create a DefaultTableModel object and pass that as parameter to the setModel method.

Whenever you want to insert a new row, just call the method addRow of your DefaultTableModel instance. You don't need to call the setModel again as long you are calling the addRow method of the same instance as the one used to create the JTable

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Did you write this code?
Your answer will determine our answer.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Since you put the username, password at the query, it means that if the query returns then the username, password given were in the database. You don't need to get the username, password from the database and compare them again. This will do:

if (rs.next()) {
 // success
} else {
 numberOfAttempts++;
 if (numberOfAttempts>3) {
   // exit   
 }
}

You'd better try to understand the code I give you and not just copy paste it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Since you don't seem to get my suggestions I prepared this small document on how to proceed:

The Address class will have ONLY these:

class Address {
  private String first = "";
  // rest attributes last, homeadd ...
  
  public Address() {
  }
  
  public String getFirst() {
    return first;
  }
  public void setFirst(String first) {
    this.first = first;
  }
  
  // rest methods for last, homeadd ...
}

Read the class Vector. Look at the methods add, get, size

class AddressBook {
  public Vector addresses = new Vector();
  
  public AddressBook() {
  
  }
}

And in the main class

public class Main() {
  public static void main(String [] args) {
      Scanner scan = new Scanner(System.in);
      AddressBook book = new AddressBook();
      String choice = "";
      
      
      // print menu
      ....
      //
      choice = scan.nextLine();
      
      if (choice.equals("1") { // add contacts
        Address ad = new Address();
        // read the data from the keyboard (scan.nextLine())
        // use the set methods (ad.setFirst(...)
        book.addresses.add(ad);
        
      } else if (.. "2") { // See if a person is in the address book
        // read the name from the keyboard
        // loop the Vector and take each Address. Then compare the name of each Address with the one given
        
      } else if (.. "3") { // View contacts in the address book
        // loop the Vector, take each Address and print its values
      
      } else if (.. "4") { // Exit
        
      } else {
        System.out.println("Error choice");
      }
  }
}

You might want to put the part …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I prefer the first method with the BufferedReader, with a small change:

public void readMethod() throws Exception {
BufferedReader br = null;
	try {
		br = new BufferedReader(new Filereader("osaka.txt"));
			String strLine;

			while ((strLine = br.readLine()) != null)   
			{

				System.out.println (strLine);
			}
		}
		catch (Exception exc)
		{
                        throw exc;
		} finally {
                       if (br!=null) br.close();
               }
	}

And call it like this:

try {
 readMethod();
} catch (Exception e) {
 System.out.println("Error: "+e.getMessage());
}

I would suggest, the method to return a Collection of objects that the file contains:

class Athlete {
  // Have as attributes these:
  // Lane    num   Name                    Nat   Time
  private int lane;
  private int num;

  public Athlete() {

  }

// add get,set methods
}
class Heat {
  private Athlete [] athletes = new Athlete[8];

  public Heat() {
  }

// add methods for getting and setting the values of the Athlete array
}

You method should return a Vector of Heat. Check the API for the Vector class.
Now in another class do this:

class Main {
public static Vector readMethod() throws Exception {
.....
}

public static void main(String args[]) {
   try {
     Vector heats = readMethod();
      for (int i=0;i<heats.size();i++) {
           Heat ht = (Heat)heats.get(i);

           // now you have each Heat in an object. Each Heat has 8 athletes with their scores. So you can calculate whatever you want
      }
  } catch (Exception e) {
   System.out.println("Error: "+e.getMessage());
  }
}
}

Your only problem now is reading the file and parse it so …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you have a form with a servlet you have sth like that:

<form action="someServlet">
  ... data to be sent
</form>

For a link:

<%
String name = "a";
String pass = "a";
%>

<a href="someServlet?[B]name[/B]=<%=name%>&[B]password[/B]=<%=pass%>">
  Click Me!
</a>

Instead of <%=name%> you can have whatever you want:

<a href="someServlet?[B]name[/B]=1111&[B]password[/B]=2222">
  Click Me!
</a>

Or you can have more:
"someServlet?req1=111&req=2&req3=3&req4=4"

And at the servlet get them like this:

request.getParameter("[B]name[/B]");
request.getParameter("[B]password[/B]");
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I had checked the Sun tutorial but still stuck... i'm now trying to figure out the getSelectedValue mentioned in the first post...

In that tutorial there is this code:

String petName = (String)cb.getSelectedItem();

Where cb is the JComboBox. In the tutorial that piece of code is called whenever the comboBox is clicked, but you can call that method whenever you want. When you click the button call that method.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hi if i need help can someone help me here?i am a student of computer science but im not good in programming T_T

Start a new thread with your question

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Look at API for the class JComboBox. There is a method called: getSelectedValue or something like that. It returns an Object. You can use that to get what is selected.
If what is added in the ComboBoxes are Strings then you can cast the result of the above method to a String.

You can have one button. Once clicked read the values from all comboBoxes

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Don't hijack other's people threads mzashi hassan, and do your OWN homework. We will not do it for you.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As I said in previous post, don't create a ResultSet and leave it open.
Have an object like this:

class Patient {
  private int patientNo;
  private String fName = "";
  private String lName = "";
.....

  public Patient() {

  }

 // have methods for getting, setting those values:
 public int getPatientNo() {
    return patientNo;
  }

 public void getPatientNo(int patNo) {
    this.patientNo = patNo;
  }
}

Then have a method like this:

public Patient getPatient(int patientNo) throws SQLException {
  // do the things I told you in your other post about how to read data from DataBase

  // if results found create a Patient object and return it
}

Then call the above method, get the Patient objetc and get its values. Then you can do whatever you want with those values.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Becuase you do this:

while(rs.next()) {
  if (success) {
     show page
  } else {
     error
  }
}

If you give wrong credentials the error message will be printed many times since it is inside a loop. Assuming that you have many entries in the database and only one matches the values you entered. When you reach the row that has the same "username", "password" entered the patient gui will be displayed but the while will continuing looping.

I already told you the right way to do things and you didn't follow them. If you are such a beginer that you can't even create a single method that returns true or false:

Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
//open connection
//create statement
//run query that returns ResultSet

//get the data from ResultSet
while(rs.next()) {
  if ( rs.getString("username").equals(username)  &&    rs.getString("password").equals(password) ) {
     return true;
  }
}
return false;
} catch (Exception e) {
    throw e;
} finally {
   if (conn!=null) conn.close;
   // the same for st, rs
}

Or can't even write a query such as this:

public boolean validate(String user, String pass) {
  String query = "select username, password from LoginTable where  username = '" + user + "' and password = '" + pass + "'";
}

Or follow this simple structure:

// declare Connection, Statement, ResultSet
try {
// Initialize Connection, Statement, ResultSet
} catch (Exception e) {
    throw e;
} finally {
   // close Connection, …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you want us to convert that!?!? You must be out of your mind. Do you even know java?
You need to know java and have some understanding in php.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all you need to close the connection, statement and resultSet every time after you have used them.
Second try to print the stack trace of the exception. (e.printStacktrace()). And try to find at which line of the class you get that exception. If it is a NullPointerException, which probably is, it means that you are using something which is null, that you haven't initialized.

And have a seperate class that does the database handling. Have a seperate method that does this:

Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
open connection
create statement
run query that returns ResultSet
get the data from ResultSet
return;
} catch (Exception e) {
    throw e;
} finally {
   if (conn!=null) conn.close;
   // the same for st, rs
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Yes I could

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public void print(){
System.out.println("Address Book Contacts "+contacts[i]);
}

Where do you define 'i' at the above code? That is why you get the error.

Also you will have many Addresses at your program. Meaning that you will have a collection of Addresses. So why do you put the printMenu and functionality in that class.
Have this:

public class Address{

      //Declare variables
      String first;
	  String last;
	  String homeadd;
	  String homeph;
	  String cellnum;


	  public Address(String firstName, String lastName, String homeAddress, String homePhone, String cellNumber){
	  	first=firstName;
	  	last=lastName;
	  	homeadd=homeAddress;
	  	homeph=homePhone;
	  	cellnum=cellNumber;
	  }

public Address() {
}

// have methods for getting and setting the value of the class

In another class, in the main method you will have your menu and you will create instances of the class Address

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Assuming that you have read the number.
- Use an "if" to see if it is greater than 2. Remember you need the sum of numbers from 2 till the number given.
- Have a for loop for the sum:

for (int i=[B]2[/B];i<=[I][B]givenNumber[/B][/I];i++) {

}

I hope that you know how to calculate the sum of numbers using a for loop.

And as for your question use the '%' operator. If:
D = a*b + y. Then:
D%a = y
D%b = y

So for even numbers use this:

if (number%2==0) {
  // number is even
}

Since the above if returned 0 it means that it can be divided by 2, so it is an even

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Are the data saved correctly? If the problem was only with the reading then you didn't have to post all this code, because that will make people reluctant to reply. I would suggest this:
Have a separate class with methods for reading and writing:

class IOManager() {
   public static void methodForWriting(File file, .....) {

   }

   public static <List of objects you want to return> methodForReading(File file, .....) {

   }
}

And in another class test them:

public static void main(String [] args) {

  IOManager.methodForWriting(....);
   // open the file to see they are written

  IOManager.methodForReading(....);
  // print what you get
}

Once you get them to work call them from your main class where you have the functionality for those operation, or post any troubles you might have.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

All I would do is create a separate thread and start it whenever I want:

class MyThread extends Thread {

}
MyThread mt = new MyThread();
mt.start();

Now in the run method you can try something like this:

int count = 0;
while (count<10) {
  try {
     Thread.sleeep(1000);
     // beep;
  } catch (Exception e) {
  }
  count++;
}

Since the while repeats every 1 second, you can use the "count" variable to count 10 seconds.

Or you can use the "System.currentTimeMillis()" method to get the time in milliseconds and save it into a variable.
At the while statement compare that variable with the currentTimeMillis taken each time and if their difference is more than 10 seconds (10000 millis) then stop the loop

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also you are making the same mistake you did in your initial post.
Remember, in order to print the text value of the node you are using this method:

System.out.println(node.getNodeName() + ":" + node.[B]getTextContent()[/B]);

So why are using this: node.setNodeValue("") in order to change its value?

Use the equivalent setTextContent("") method.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Start a new thread

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is how you instantiate an Object:

NameOfClass noc = new NameOfClass();

Not like this:

[B]OutputStream[/B] = new FileWriter("timeremaining.txt");

And call the methods like this:

noc.method1();
int a = noc.method2();

It seems to me that you don't know the very basic of instantiating objects so forget about the reading from file stuff and practice more on the basics

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Thanks Again and next time I'll start a new thread.:icon_smile:

Then start a new thread. Also what you are doing is wrong at the actionPerformed.

You need to get the PatientNumberList.getSelectedValue() and run a "select" query based on that value every time you click the button.
Create an object with properties all those values that you want. In a separate method, open the connection, run the query, get the results and put them into that object. If PatientNumberList.getSelectedValue() is the primary key you will get only one row. Then close the connection, statement, resultset and return the object.
Then call the method in the actionPerformed with argument the PatientNumberList.getSelectedValue().

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

1) Did you import their package? // import java.io.*;
2) Java is case sensitive: OutputStream, InputStream
3) Do the above and then post code if they don't work

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There is a problem with your brackets. You do this:

if (conn!=null) {
  try {
  }
} catch () {

}

Whenever you open something close it immediately and then write inside it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use the equals method to compare Strings:

if ( ht.equals("h") ) {

}

Also you don't need to declare your integers Integer. Simple int will suffice:

int x=8,y=1,heads=0,tails=0;
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also a good way to find out what type of node you have is this:

public static void main(String[] args) {
        System.out.println("ATTRIBUTE_NODE             :"+Node.ATTRIBUTE_NODE);
        System.out.println("CDATA_SECTION_NODE         :"+Node.CDATA_SECTION_NODE);
        System.out.println("COMMENT_NODE               :"+Node.COMMENT_NODE);
        System.out.println("DOCUMENT_FRAGMENT_NODE     :"+Node.DOCUMENT_FRAGMENT_NODE);
        System.out.println("DOCUMENT_NODE              :"+Node.DOCUMENT_NODE);
        System.out.println("DOCUMENT_TYPE_NODE         :"+Node.DOCUMENT_TYPE_NODE);
        System.out.println("ELEMENT_NODE               :"+Node.ELEMENT_NODE);
        System.out.println("ENTITY_NODE                :"+Node.ENTITY_NODE);
        System.out.println("ENTITY_REFERENCE_NODE      :"+Node.ENTITY_REFERENCE_NODE);
        System.out.println("NOTATION_NODE              :"+Node.NOTATION_NODE);
        System.out.println("PROCESSING_INSTRUCTION_NODE:"+Node.PROCESSING_INSTRUCTION_NODE);
        System.out.println("TEXT_NODE                  :"+Node.TEXT_NODE);
        /*
        System.out.println("DOCUMENT_POSITION_CONTAINED_BY:"+Node.DOCUMENT_POSITION_CONTAINED_BY);
        System.out.println("DOCUMENT_POSITION_CONTAINS:"+Node.DOCUMENT_POSITION_CONTAINS);
        System.out.println("DOCUMENT_POSITION_DISCONNECTED:"+Node.DOCUMENT_POSITION_DISCONNECTED);
        System.out.println("DOCUMENT_POSITION_FOLLOWING:"+Node.DOCUMENT_POSITION_FOLLOWING);
        System.out.println("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:"+Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
        System.out.println("DOCUMENT_POSITION_PRECEDING:"+Node.DOCUMENT_POSITION_PRECEDING);
        */
    }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all here is a small misconception:
This:

<VERSION>3.1</VERSION>
<SMTPSRV>blue</SMTPSRV>

is not Two nodes but Three!

Node 1:
<VERSION>3.1</VERSION>

Node 3:
<SMTPSRV>blue</SMTPSRV>

Node 2:

<VERSION>3.1</VERSION>
<SMTPSRV>blue</SMTPSRV>

The new line character between </VERSION> and <SMTPSRV>

So when you print this: System.out.println(node.getNodeName() + ":" + node.getNodeValue()); For Node <VERSION>3.1</VERSION> :
You have Name = VERSION,
Value is null, because <VERSION> doesn't have a value

And for the new line:
Name: Doesn't have a name because it is just text in the file so you get #text
Value: you get the new line character, which is why you get that empty line.

Try printing this:

System.out.println(node.getNodeName() +":"+([B]node.getNodeType()[/B]==Node.TEXT_NODE)
+":"+[B]node.getNodeType()[/B]);

You will see the it is true only for the #text, and for the nodes whose values you want is >1<

So you can do this to avoid the free text that is between the nodes in your file:

<VERSION>3.1</VERSION> [B]<new line>[/B]
[B]<some spaces>[/B]<SMTPSRV>blue</SMTPSRV>
       <SMTPPORT>29</SMTPPORT>
if (node.getNodeType()==Node.ELEMENT_NODE) {
   System.out.println(node.getNodeName() +":" + node.[B]getTextContent()[/B]);
}