javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Given from your last PM apparently you don't know what forums are and what they are for.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

anybody online there,
i want the solution of my problem.i will feel free to discuss the code of my aplication

You were very smart to PM me the description of your problem and then posting again asking for the answer without explaining anything.

Then double posted asking the same thing. As if we didn't want to give you the solution but after the second you made us change our mind.

You say "give me the solution". How are we supposed to know what is your problem.

No we won't give you the solution, unless you post at the right Forum (the JSP forum) following the rules of this forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That's because this for loop is never executed:

for (index = 10; index > array.length; index--)
                arrayCopy[index] = array[index];

'index' has value 10, array.length has value 10.
you say: index > array.length; which translates: 10 > 10 . It will return false and you will not go inside the loop.

Since you set index to be 10 (It is WRONG. Should be 9 ) and then you decrease it, the boolean expression shouldn't use the 'array.length'
You already start from 9 and then go down, so you don't need to check the upper limit.
You need to stop when the index reaches 0: index >= 0; Also if one array used index: arrayCopy[index] the other should use something else because with the way you have them the same elements will go at the same place: arrayCopy[index] = array[index]; .
Doesn't matter that you start from 9 and go to 0

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.

No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point to use unicode then

puneetkay commented: Thanks for helping! +2
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You may need unicode to print characters that are not supported. Like having an application that needs to print messages in various languages (English, German, Chinese) depending on user's selection.

It is used for internationalization. In one of my projects we had different property files used for resource bundles to print messages in different languages. For languages like English, French we had normal characters, but for Chinese and others we used unicode.

Unicode is also used for printing unsupported characters in HTML pages

But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.

Meaning that you should name a method like:
> getNumberOfUsers

but not:
> epestrepseArithmoChriston

The later translates to the first method but you shouldn't name methods using your native language with english characters. Someone else might want to read the code.

It happened to me where we had to debug an entire application written in Italian. Not a clue what was going on. Babel Fish became my best friend

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can we see part of the code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Like I said in my first post:
START A NEW THREAD

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I think there is a method called setMaxAge() for Cookies.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can have the class extend the Thread class.
If you don't want to change the code of the old class though you can try to create a new one that extends the old and implements the Runnable interface:

Runnbale

public NewClass extends OldClass implements Runnable {
   
  public void run() {
      ......
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Maybe the username_ctr which you increment inside the catch becomes greater than 5.
Meaning that you need to add some debugging messages like printing the value of username_ctr.
Also I believe that you are sure that inside the catch you don't get another exception?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Start your own thread, and
In the database, where you store the usernames and passwords you can have an additional column that indicates if the user is admin or not.
When you login get that info along with the username and password. If the user logged in successful, use the info that was read from the extra column to decide where to redirect.
Also save in the session if the user logged in is an admin or not to check that whenever you go to to other pages

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It should have solved your problem if you followed our suggestions and if you have done it right.

Do you have some code for us to see?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you read carefully the main code you will see how the class is being initialized and used. The class extends JPanel. You cannot initialize it and use it on its own the way you think.
Read about java swing and how to create GUIs. Try to understand how JPanels are used

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Firstly I don't believe that this is your code.

Secondly look at the API of the File class. It has a method that accepts a filter and returns the file names that satisfy that filter.

The method is similar with the one used at the code so would be able to figure out what to change.

And most important: USE CODE TAGS

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to get the values from the List, put them into 2 different variables and compare them.
But you can compare them directly from the List as well:

if ( list.get(i).equals(list.get(j)) )

Remember the list.get(i) as a whole is a String.

I suggest you explain your entire problem because your questions had me confused regarding what you are trying to achieve, because I believe there might be a different way to do what you want.

----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
PS: This has nothing to do with this post or the poster. It is for whoever is watching.:
1) I don't answer PMs with stupid questions
2) If someone wants to say something just send me a PM with what they want.
3) Me being online or not has nothing to do with my ability to receive PMs. If someone sends something I will see it the next time I login

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Yes

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

> If you are sure you will have only 2 Strings then you don't need the List.
> If you need to compare 2 Objects first you will need to get them into separate variables. You have to be more specific on what you want because, You will need to have at least one of them and then loop the list to find the other.
> Definitely for Strings and usually for other Objects use the equals() method.

This:
if (String1 == String2) checks if they are the SAME Object.
This:
if ( String1.equals(String2) ) checks their values.

Use the equals()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Let's see some code first because your questions doesn't make any sense

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Usually when I use SimpleDateFormat I always use this method:
SimpleDateFormat.setLenient(boolean)
I set it to false in order for the parse, format methods to throw an Exception if the String I am trying to parse isn't an exact Date according to the format

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

From what I understood, first you delete and then you insert, when you want to do an Update.

Well you can try and run an Update query. When you "SELECT" data from the database you use a userID as you say in your example. Probably you use it at your "WHERE" clause at the query to get the data (UNIMP and IMP).
You can have ONE update query setting the values of the UNIMP and IMP data taken from the TextFields.

Or if for some reason that cannot be done, you can use "commit", "rollback".
First set the autoCommit of the connection to false.
Run your queries.
If both where executed: commit and set back the connection's autoCommit to true
Else if there was an exception do a rollback inside the "catch (Exception e) " and again set back the connection's autoCommit to true

All the above methods are available from the Connection class. Check its API for more info

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You mean you didn't notice methods like: get(int i) or size() ?
Do you know how to write a simple for loop?

for (int i=0;i<list.size();i++) {
  Object obj = list.get(i);
}

Get the objects and compare them.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you checked the API for List?
When you say the same, you mean the same Object (reference) or the Objects have the same value?
Have you tried looping the List?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can have a variable take a specific value in the method, and then check that variable's value.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

SimpleDateFormat class is needed

......
       String yourdate="12-Aug-2009";
       String currformat="dd-MMM-yyyy";
       SimpleDateFormat fd=new SimpleDateFormat(currformat);
       Date d1=fd.parse(yourdate);

       System.out.println(d1);
       String newformat="dd-MM-yyyy";
       fd.applyPattern(newformat);
       StringBuffer b=new StringBuffer();
       System.out.println(fd.format(d1,b,new FieldPosition(0)));
       ....

You could have printed this:

//fd.format(d1)
System.out.println( fd.format(d1) );
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Add a log message in the function.
Example: System.out.println( "Method called" )

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The fact remains that you took the class that lasted several months. Meaning that all this time you should have studied. We have taken many exams on subjects that were for only 1 year and we would never come across again but that is not an excuse not to have studied.
Yes we would have helped you and provide you with solution under different circumstances but the simplicity of the questions indicates that you didn't study anything because the answers are very basic and easy. These are the first things that you get taught. So I see no reason to help you cheat.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I took this example:

<select multiple="multiple">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

From this site:
http://www.w3schools.com/tags/att_select_multiple.asp

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i need to extract the number part from the string which looks like "(7 r 8digits).txt". i need to store this found string in some variable, but i am confused wih the groups twhether o get the string as group() or group(1).

Pattern p = Pattern.compile("\b[0-9]{7,8}\b");
Matcher matcher = p.matcher("num"); //where num looks like10986745.txt r 0986745.txt
String identifier = matcher.group();
System.out.println(identifier);
But i am getting the output as no match found.
So it would be very helpful if some one would clear this

I deleted your PM. Start a new thread

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you have somewhere another class named Random?

freelancelote commented: thanks a bunch +1
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

For calculating the sum try something like this:

1+2+3 + ... + i + ..

int sum = 0;

for (int i=1;i<N;i++) {
  sum = sum + i;
}

Also there is this method: Math.pow(a,b) .
Calculates the power:
Math(2,3) = 2^3 = 8

Now let's see some code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can try the .charAt() method of String class

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well, the first hint would be the exception itself, which you did not specify here.

I would recommend using executeUpdate() which returns the number of rows affected instead of executeQuery(), which return a result set.

I thought that you cannot use executeQuery for "insert", "update", "delete" queries.
Anyway apart from using executeUpdate maybe you should leave a space between 'Taken' and WHERE:

String sqll ="UPDATE Patient_Comp SET taken='Taken'WHERE ID="+x ;
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

dis shite shzucks

You will find no servants here that are obligated to answer to your questions. If you didn't get a reply it was probably because people didn't know the answer or they were busy with their own (personal or not) problems.
No one here has anything against you so not to answer to your post. Don't act like we didn't answer because we had some grunge. I don't know you. If I had something useful to say 3 months ago, I would have said it.
No one offended you. No one guaranteed that we will immediately solve all your problems

VernonDozier commented: Well said! +16
Ezzaral commented: Agreed. +23
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It depends on how you want to parse it.
If you managed to read each line in the 'record' variable perhaps you should look at the String class. There are methods like split() and substring()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have two database's
1st database has 21 columns and 20140 records
2nd database has 27 columns and 61603 records.
i need to compare each and every cell of 1st database to each n every cell of 2nd database and the output should be the rows where two cells are matching from both database's.

plz help me to gt java source code for tht

No one can answer that question and do you know why?
Because even if we wanted to hand you the code, which we won't, how are we supposed to compare 2 databases when we don't know the database names, hosts, ports, usernames, passwords, the table names and the column names?

Haven't you said in your previous posts the you have the code and that you will post it next Monday?
Do you know how many Mondays have past?

We would have helped you if you asked specific questions. Do you know how many examples are in this forum on how to connect to a database using java code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also another thing:
Outside the constructor you do this:

int n;
int array[] = new int[n];

In that way you set the array to be 0 size, since 'n' is zero. I believe that 'n' should be the argument of the constructor:

int N;
int array[] = null;
int top;
public stack(int size)
{
N = size;
array[]= new int[N]
top = 0;
}

Why do you set 'top' to be 2. It makes no sense. Top ,as you said, should point at the top of the stack. If you initialize it to '0' then top would be the place where the next int should be place, since arrays start form '0'.

Meaning that you don't need to iterate the array at the pop, push methods. Whenever you want to add an int,
put it where the 'top' index shows: array[top] = value; and increase the 'top' so next time when you call push, it will put the next int at the increased 'top'

The opposite thing will happen when you want to pop. You need to remove the "top" element of the stack.
So you will return the top element and decrease 'top' by one. Be VERY careful because 'top' points to where the next element needs to be put. So you need to decide whether
first to return the array[top] and then to decrease, OR
first decrease the 'top' and then return the array[top]

When you pop elements …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i dont understand why adatapost is obsessed about increasing his solved post numbers. i cant see any other useful motivation for this behaviour of approving the previous posts.

If you see how adatapost's reputation goes up and down you will realize that you are not the only one who has noticed that

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The answer is simple English grammar:

A method throws an Exception:

public void method(int i) throws Exception {

}

The method throws an Exception when you call it


But you throw an Exception:

if (i<0) throw new Exception();

If 'i' is negative you will throw an Exception.

And if you put it together:

public void method(int i) throws Exception {
      if (i<0) throw new Exception();
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Declare an int variable and whenever you do a comparison increase its value by one

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Where do instantiate the JTextArea? It should be somewhere were is "visible"(not out of scope) form your main. Also if you want it to be displayed you need to attach it to a JPanel, the JPanel to a JFrame and then you need to instantiate the JFrame and set it to be visible. JTextArea will not be displayed no its own

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean the list is nested?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i do n't know what have you done in

changeItemValueNew(form,z,y)

method

We still don't know if the code before the call of that method is executed

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Create the variable in the javaScript
and store the value in it
then use it

var   z=productCode;
var y=index;

I don't believe that it will solve the problem. If this will execute correctly:

var   z=productCode;

changeItemValueNew(form,z,y)

then this will also:

changeItemValueNew(form,productCode,index);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Obviously you will need a for loop and some if statements (or a switch statement).
If you don't want 100 ifs try to create 2 arrays with elements:
"zero","one","two",..
and
"twenty","thirty",..

How many elements the arrays will have and how to use them is something for you.

I assume of course that you want what masijade has described, since you failed to explain your problem

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all describe better what do you mean by this:
after giving that alert messsage it works otherwise not.

Also, firstly does the method being called correctly?

Try this to check the above:

function changeQuantity(form,productCode,index)
{
alert("Method called");
}

Then see if the arguments are passed correctly:

function changeQuantity(form,productCode,index)
{
alert(productCode);
alert(index);
}

Then try your code with alert messages between the other commands (like debugging) to see what is wrong

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you looked at the API of the String class?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Thanks for reply....
It's not working..
when i first time load my project it gives me error like i is undefined
But after giving an alert it works fine...

What do you mean giving an alert. Post the code that works

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

post relevant code