masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would, but I have not a clue what you just said.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, your actual probelm is that connection is probably not defined. But that is beside the point. Scriptlets have no place in JSP's anymore. Youre still allowed to use them (mainly for backwards compatability), but you shouldn't be using them. It makes maintenance of the application a living hell.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't use scriptlets in your JSP. Move this out into a Bean. If you still have a problem, post the Bean, and the JSP tags you use to access it, and we'll continue.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is a continuation of http://www.daniweb.com/forums/thread120574.html

Please stick with that thread. I have asked the admins to delete the third thread you created and asked them to close this one.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And? What's it doing?

Are you getting compiler messages?

Are you getting an exception?

Are you seeing an unexpected effect?

In short, what is wrong?

Post the complete messages, and, if it's the third, a complete description of what you expect and a complete description of what you actually get. (And repost your code using code tags please.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

this, which you already have,

f.setLocationRelativeTo(null);

should already take care of that.
Have you tried it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Firewall?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Be more than happy to help you. Once you show us what you have. We are not going to do it for you, though.

You need, JFrame, JLabel, JTextField, JButton, GridLayout (as the easiest), ActionListener, and Random.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You need to close your resultsets, statements, and connections (in every place you're using them).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

God, I'm blind sometimes. Your error is not there (at least not this error). Your error is this

String[] serv=null;


serv[0]=String.valueOf(port_array[0]);//seending the port # of client who has the server socket

You set the String array serv to null, then attempt to access an index of that array, which will, of course, throw a nullpointerexception since serv is null.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your error then, seemingly occurs in this method
"enterintodb"
as that is called before the other (and the output around it is not contained in your output).

Also, the stack trace is all the other information that comes with that nullpointerexception. One piece of that will actually point you to the exact line where the error occurs. Which line is that?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then what is this
"Unable to connect to the database in authGeneral error"

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You could start by using the correct class

javax/swing/plaf/metal/MetalLookAndFeel

There is a file called classlist in the lib directory of the JRE which contains a complete listing of the classes in the JRE.

Kusno commented: Thanks a lot......!! +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

The basis of your error, however, seems to be that you cannot connect to the DB. Are you sure that that the dsn is defined as "MS Access Database" as you have in your code.

If msk is the DSN (as your comment suggests), then use that.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
server.lookupserver.main(serv);

Where is any of the above (aside from the String array serv) declared and/or defined.

According to your code, server is a package, so the only way this could possibly work, is if "lookupserver" were a class within server, and main a static method in that class.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Seemingly

com.sun.java.swing.plaf.metal.MetalLookAndFeel

doesn't exist.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just wanted to make sure the OP understood. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It's perfectly fine to have return statements within if() blocks. The issue here is that there is not a guaranteed return path from the method. For instance, in the original code if inOrder.length is 0, there is no return. The compiler requires a valid return path regardless of any conditional statements and that is why you could not compile it.

Yes, you can return from an if. However, if the only return statement you have is contained within an if statement, and the compiler cannot confirm that every possible avenue has been covered, you will still get a "missing return statement".

i.e.

public String aMethod() {
  int x = 0;
  //do something with x
  if (x == 0) {
    return "Hello";
  }
}

will cause the compiler to throw that error, as the compiler cannot confirm that something will be returned. If you are going to return from an if statement, then return from every block in the if statement and include an else that also has a return statement or have a return statement at the end of the method.

i.e.

public String aMethod() {
  int x = 0;
  //do something with x
  if (x == 0) {
    return "Hello";
  } else if (x == 1) {
    return "GoodBye";
  } else {
    return "Bogus";
  }
}
// or
public String aMethod() {
  int x = 0;
  //do something with x
  if (x == 0) {
    return "Hello";
  }
  return "Bogus";
}
// or
public String …
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why u repling so stupid ans..He wants to find current running applications using java in his application and u r repling go to wnodow prompt....If u hv some decent ans rep otherwisw no need 2 rep

Because, his question was not about how to use Runtime.exec. He, suppossedly, knew how to do that already. His question was about which command to use, and that has absolutely nothing to do with Java, and so did not belong on this forum. So the advice given (to ask on a Windows forum or do some searching on his own) was spot on. Whether you like that fact or not does not concern me.

It also had, still does not have, absolutely anything to do with JSP, even if he was asking about how to use Runtime.exec. So keep your opinions to yourself, or at least make your remarks relevant. Anything else is a simple, whining, rant.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course, that second part of the if statement is completely false anyway. That is what the for loop is for.

public static int nameSearch(String[] inOrder, String searchedFor){
    int returnVal = -1;
    if (searchedFor == null) {
        // if searchedFor is null the if in the for loop will have problems.
        return returnVal;
    }
    for (int i = 0; i < inOrder.length; i++) {
        if (searchedFor.equals(inOrder[i])) {
            returnVal = i;
        }
    }
    return returnVal;
}

P.S. You can't set an int to null anyway. ;-)

And, don't use == to compare Strings. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

this error message is quite self-explanatory

Play.java:5: Play is not abstract and does not override abstract method keyReleased(java.awt.event.KeyEvent)
public class Play extends JApplet implements KeyListener, FocusListener, MouseListener {

You have implements KeyListener and have not (in that class) implemented (i.e. defined) the method

public void keyReleased(KeyEvent e) {
  // your code
}

If you take a close look above, both your "Play" class, and your "Game" class claim to implement a couple of interfaces, but only "Game" actually defines the methods declared in those interfaces.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

setCaretPosition

Read the API docs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

in pseudocode

time=getCurrentTimeInMillis
rs=stmt.executeQuery
time=getCurrentTimeInMillis-time

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why don't you look at the source code for nextDouble (or some other method) of the java.util.Random class?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What did I say? I said the Vector contains only the values, not the views. You need to declare and use a specific Renderer on the Column that needs one. Read the tutorial again, because you seemingly did not understand it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The vector contains the data in the cells, not how it is to be displayed. What you need to change is the CellRenderer.

See the Swing JTable Tutorial paying special attention to the Using Custom Renderers section.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, do what the warning says and run javac using the "-XLint" option. That will tell you what is deprecated, and you can then look at the API doc for that method and that will tell you what you should be using.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because accept blocks until it gets a connection attempt. You should be placing your network (and all other operational code) into a different thread from your GUI code, because when you attempt to perform an operation on the Event thread, the GUI will not respond until that operation is finished. And, if that operation takes a long time (or blocks) your GUI will be unresponsive until that operation finishes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you noticed, that piece of code still doesn't import anything from java.io ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why don't you simply use String's split method and ignore the last resulting index?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Let us see your code and we will help you correct (when you tell us exactly what errors you are getting), but this is not a homework service. We will not do it for you. That is, in fact, against the terms of use that you agreed to you when you signed up here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Fix your imports. You seem to be attempting to use a lot of classes without ever having imported them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You're more likely to get help with the problem if you explain the problem briefly -- rather than just posting a block of code and expecting others to actually find the problem aswel.

Not only "more likely", but more like "required". I for one, and most others here, will not even bother to glance at the code without much more, and detailed information.

What compiler messages are you getting?
What runtime error are you getting?
What output do you get that you did not expect (and what did you expect)?
What output did you not get that you expected?
etc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do have an auto-incremented or auto-generated field as your primary key?

If so, you won't be able to prevenet duplicate inserts, only on the base of the primary key. You will need to define an additional unique index (and it can be a single index that spans multiple fields) that actually uses the data you will be inserting.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try removing that ",Statement.RETURN_GENERATED_KEYS". Your code isn't make use of it anyway.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I believe it is because of this

Statement stat = myConn.createStatement();
PreparedStatement updaterecord;
String query="INSERT INTO logspi01 VALUES(?,?,?,?,?,?,?)"; //tem que ter o mesmo numero de campos da DB
updaterecord = myConn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);

See http://java.sun.com/products/jdbc/faq.html#15

Get rid of "stat", which you are not using anyway.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
for (double i = 0; i <= arraylength; i++)

array indexes are ints, not doubles. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But you don't want to limit his creativity, do you? ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So search the document. There is a search function in it. Search for something like Creating or Establishing a connection, and the information (and usually at least one example) will jump out at you there.

My God, that nobody reads anything these days.

You could have had your info, and fixed your app already, in the day+ worth of time that you've spent on this question at this forum, by simply using the search function in the documentation that came with the Driver.

And I do mean the JDBC Driver documentation. There is no reason to read the entire DB documentation (of course), yet, at least.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, there are al sorts of links on the site where you download the Driver from, at a minimum.

Where did you download your Driver from? The vendor, I hope.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You have downloaded the DB2 Driver, right? Did you actually read the documentation that came with it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You have no MenuItemListener

masijade 1,351 Industrious Poster Team Colleague Featured Poster

http://java.sun.com/javase/6/docs/api/java/util/HashMap.html

Edit: P.S. The API docs are a wonderful thing. They answer all sorts of questions.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Arrays.sort, then take the first and last element for the min and max.

If you are not allowed to use that, and if it is an exercise you probably won't be. Simply declare two variables before your averaging loop, and initiate them with the first element in the array, then with each element compare the element to the variables giving the variables the value of the greater and lesser value.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is no "menu" anywhere in that code. A bunch of Buttons, but no menu, so what exactly is your problem?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use a Dialog.

Kusno commented: Thanks a lot bro..... +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use a map.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do you know what a try/catch block is (I hope you do if you're using JDBC)? If so, then, simply put the execute statement for the insert inside of its own try/catch block, and when the insert fails due to duplicate keys, simply ignore that record and go on to the next.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Oh come on man.. i want a FRAME.. a window.. don't limit my creativity :(

You do know that you can handle a Dialog (or JDialog) in exactly the same way you do a JFrame, except that you do not have, per default, the min max buttons on the frame, right?

You don't have to use JOptionPane. Suggesting the use of, or using, a (J)Dialog does not "limit your creativity" in anyway, and it makes a few things in your life/coding much easier.

Edit: And a Dialog is a Window.