masijade 1,351 Industrious Poster Team Colleague Featured Poster
java test.Main

not

java test\Main
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Did you create an "AddressBook" DSN?

If not do so or Google "DSNLess connections".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The concept is fairly simple, when you can use "temp" references. It's when you can't that it gets hard.

n1 = getNode(idx1)
n2 = getNode(idx2)

temp = n1.next
n1.next = n2.next
n2.next = temp

temp = n1.prev
n1.prev = n2.prev
n2.prev = temp

This is, of course, not thread-safe, though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No difference. local variables get their stack addresses at the method level, so there is, truely no difference. Unless, of course, you wish to use that variable outside of the for loop.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

ok i'll c 4 mysql then.. i was tryin to solve it though java.. it seems little aukwrd no? thankx any way

The "solution" may be executing a specific SQL statement. In which case you can still use Java to execute it (even automatically within the life of an application), but Java cannot solve it.

Edit: Then again, the answer may be that you can't. That you would have to "recreate" the counter and repopulate the table with new values.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But The problem may be, is that when you delete the records, the pointer for the next field to add is still at 16

Exactly.

and all you need to do, is insert in field 6 for example.

Yes, as already said, you can manually insert into (or update) this field, but that does not reset the counter.

probably you need to google that.
"how to manually insert in a field" or " how to override a field " that could give you an idea about the auto numbering in my opinion.

No, I'm sorry, but his best bet, as already said, is to read the manual (again if need be) first, then to ask (using a forum search there first) at the forums (and/or a mailing list) at www.mysql.org

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but, this is a MySQL question, not a Java question. Go to www.mysql.org and find, and ask at, the forums there.

If you want to solve it with Java, the only thing you can do is to read all the keys, finding the missing numbers (i.e. 1 and 3 are used but 2 is not) and fill those values, as well as the continuing indexes (as that will not show what the last one used was) manually.

The MySQL documentation (of which there is a lot) may give some indication of how to reset the counter, though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just simply don't include that field in the insert. i.e. you have table with field1 and field2 and field1 is auto_increment and field2 is varchar. So your query is insert into table (field2) values ('a')

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The same way you're using the other methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Instantiate your class in the main method and access those values through the reference

pulic class Bogus {
    public int x;
    public static void main (String[] args) {
        Bogus b = new Bogus();
        b.x = 5;
        System.out.println(b.x);
    }
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what is wrong now? We can't read your mind, and I am not going to play both compiler and JVM and try to reconstruct it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The exception shown say it can't find main. The main method needs to have the following signature if you intend to use it to start your program

public static void main (String[] args) {

yours is

public void main (String[] args) {
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Personally, working with that framework, I would replace that while loop with

if ((pwrd.next()) && (pasWd.equals(pwrd.getString("Pword")))) {
    return true;
} else {
    return false;
}

Edit: And, of course, add some sort of log message, or something to that catch block. Also, you must also add a return false to that catch block, or throw an exception from the method, as, otherwise, in the case of an exception, there is still no return statement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, you know what you intend, but the compiler does not. The compiler sees that you have declared the method boolean, but that if the while condition evaluates to false that there is no return value.

What, exactly, are you attempting to do with this method. I mean, I see what you are doing, but I don't know that it would actually do what you intended it to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What happens when pwrd.next() returns false? What is the return value then?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

For your java version simply type
java -version
for JCreator, I am sure it's documentation explains where and how to set the jdk and jre references.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Check the version JCreator is using in its preferences and then check which "java" is on your PATH. Seemingly the javac used by JCreator is newer than the java on your PATH. That is the only thing that causes this message, is when the compiler is newer than the jvm.

IOW, check again, as however you "checked" previously was not done right.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, you should put something in there even if only a log statement. Another possibility is to make the method boolean as follows:

public boolean add(String crime) {
        try {
            CrimeType newCrime = CrimeType.valueOf(crime);
            crimes.add(newCrime);
        } catch(IllegalArgumentException e) {
            return false;
        }
        return true
    }

That way, you at least know something went wrong and can inform the user, and you never want to simply ignore Exceptions (well there are a few places where you can, although you should still, at least, log them).

Edit: Then change this

} else {
            System.out.println("\t\tThat is not a valid crime. The crimes are");
            crimes.list();
        }
        crimes.add(crimeName);

to this

}
        if (!crimes.add(crimeName)) {
            System.out.println("\t\tThat is not a valid crime. The crimes are");
            crimes.list();
        }
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You entered "a" at the prompt, didn't you?

According to your enum class these

murder, arson, assault, fraud, theft, vandalism, drunk, littering, badHair

are the valid entries.

You might wish to wrap the line

CrimeType newCrime = CrimeType.valueOf(crime);

in a try catch block so that you can simply inform the user that (s)he entered an invalid value rather than having that crash your program.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

clicking jar file says :
Could not find the main class (note : I created the manifest file)

Then you either did not configure the manifest file properly, or you did not include the main class in your jarfile.

clicking bat file says:
unsupportedClassVersionError: bad version number in .class file

:( Sory to bothr so much!!!

Then, as stated before, you are not using the correct version of java for either your compiling and/or executing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By making sure the right versions of java and javac are in your PATH (not CLASSPATH), or call the proper version explicitly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

java -jar <jarfile>

As stated in the tutorial that I linked to in one of your other threads.

majestic0110 commented: Good point! +5
masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is how you create a jarfile, not how you "run it". Now, in which step are you having problems. When creating it, or when executing it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By giving your JPanel a different layout, rather than using the default FlowLayout.

http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So, waited until the last minute to do your project assignment, huh?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course, a Servlet/JSP. Or use JPCAP and try to write a sniffer (although C/C++ would be better for that). Even easier, however, is to read the access log of the gateway, as all "get" URL are logged there ("post" URLs, as well, but without the data, of course) Java is also for that overkill, though.

Edit: But what is it you really want to do? Are you simply trying to log what telephone number sent a message to the gateway?

Or are you trying to determine what telephone numbers the gateway is forwarding an SMS to (and the message itself)?

In both cases, look at the configuartion for the gateway, you can probably log the info somewhere, if it is not being logged already. But be very careful. There are probably all sorts of legal issues involved.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you are getting the "response" then you also sent the "request" so you should already have "A and B".

You need to better explain your situation and your goal.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

According to the API docs, countTokens() returns

the number of tokens remaining in the string using the current delimiter set

So, before you call nextToken on a "tokened String" with 5 elements it returns 5, after calling nextToken once it returns 4, so, what do you think is happening with your for loop?

Add

int size = tok.countTokens();

and use size in both places where you currently use countTokens() .

javaAddict commented: Good call. I didn't bother to examine it that closely +8
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then I would build a single method that takes a StringBuilder (for storing the value), and an SQL statement and set those off.

public void executeStatement(StringBuilder sb, String query) {
    try {
        Statement stmt = conn.createStatement();  // or however you wish to get/create a statement
        try {
            ResultSet rs = stmt.executeQuery(query);
            try {
                int fields = rs.getMetaData().getColumnCount();
                while(rs.next()) {
                    for (int i = 1; i <= fields; i++) {
                        sb.append(rs.getString(i)).append(",");
                    }
                    sb.replace(sb.length() - 1, sb.length(), "\n");  // replace trailing comma with newline
                }
            } finally {
                try { rs.close(); } catch (Exception e) {}
            }
        } finally {
            try { stmt.close(); } catch (Exception e) {}
        }
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }
}

...
    StringBuilder sb = new StringBuilder();
    executeStatement(sb, "SELECT * FROM tblMaze1");
    String rsMaze1 = sb.toString();
    sb.setLength(0);
    executeStatement(sb, "SELECT * FROM tblMaze2");
    String rsMaze2 = sb.toString();
    sb.setLength(0);
...
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then you need to explain better exactly what it is you are trying to accomplish. "I need the data from 12 tables" doesn't really tell us anything, and there is no reason why we should have to study your code to puzzle out and guess at what it is you are trying to do, when you could simply tell us.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
select table1.field1, table1.field2, table2.field1
from table1, table2
where table1.field3 = table2.field5

Again, this is an SQL question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because, like I said, a "join" in the where clause of your SQL query is a much better way to do it (you only need one query), and the construction of that query (as it is an SQL query) is an SQL question and not a Java question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By adding more queries?

If you mean you have "12" "mdb" files to read, then open 12 connections. If you mean you have to read information from multiple tables within the same "mdb" file, then add additional queries for them. If you need the data from all the tables combined in a single query, then you need to use "join" and that is an SQL and not a Java question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

FYI, if x is 0 then x % 2 is also 0. The second check is worthless.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

As in the response to your hijack post in the other thread

$ENV{PATH}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

So don't redirect. Have the servlet deliver it directly! As I have already said.

If the file is a pdf, set the response objects content type to pdf, read the PDF bytes and send them directly to the responses output stream.

Like I said, the servlet returns the file, it does not redirect. I never said anything about redirecting, I never even hinted at that!

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Like I have said before (and I believe to you) was write a servlet that takes a filename as one of the parameters and then have that servlet check the session information before returning the contents of the file. It is not that hard, already. I am not, however, going to just give you code for it. Try to write it. I will help you correct it, but I will not write it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? So what do you have, and what error/compiler messages are you getting from it, or what is it doing that you don't expect, or vice-versa.

You will notice the terms and conditions of this site (which you agreed to when you signed up here), forbid us simply giving you a solution to your homework (as if we would, anyway).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A buffer for what?

There are a few classes actually called buffer in the API. You did read the API docs, right?

If worse come to worse, write your own.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, they don't necessarily need to be in the same place, but it does need to be on the class path.

Say you have /classes on your classpath. And your class is my.package.MyClass. Then your class is located at /classes/my/package/MyClass.class. Assuming there are no other packages, then your file (named myfile) could be located in the following locations

/classes/myfile                          getResource("/myfile")
/classes/my/myfile                       getResource("/my/myfile")
/classes/my/package/myfile               getResource("/my/package/myfile")
                                         getResource("myfile")
/classes/my/package/some/sub/dir/myfile  getResource("/classes/my/package/some/sub/dir/myfile"
                                         getResource("some/sub/dir/myfile")
/classes/some/other/dir/myfile           getResource("/some/other/dir/myfile")
kvprajapati commented: Thanks +7
masijade 1,351 Industrious Poster Team Colleague Featured Poster

The associated errors would help. Also, provide the full path to the "root" directory of the classpath item that the class making the call resides in, and the full path to the actual file.

Also, check the access rights of the user to the file, and the directory it's in. And I hope that this "file" is not in a jarfile, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

;)

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

#! is a built-in exec. The shell script is executed in the shell declared on this line.

$1 etc are the arguments provided on the command line (or provided on the function call when used inside a function)

~ means home directory.

And I hope this is not homework.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, you should be using getString, but you should not be using "select *". You should be naming the columns. Also, per definition, a JDBC Driver need only allow access to a column once and only in the order in which they are returned. Which means that unless the columns are delivered in the following order: userID, firstName, lastName, symbol, name , you may have problems accessing them (and with the ODBC Driver you probably will, especially if it is an Access DB behind it).

To repeat, I would suggest designating the column names rather than using "*", and the column "name" may be a problem, in and of itself, since there is a large chance that is a reserved word, meaning it needs to be surrounded by quotes (or in Access, square brackets, i.e. "\"name\"" or "[name]" ). If neither of those work, attempt using the index (i.e. getString(5) ).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Make a data class with methods for the varying actions that might taken on the PDFObject and give it also an addListener and fireEvent methods. The "Panel" class to display the PDF will be added as a Listener to the data object so that it can actually display everything that changes. Then I would make an abstract class with varying methods for calling the "data" methods and I would make all of my swing listeners extend this class. Those swing listeners then simply need to call the method from the abstract class which will then call the "data" method.

If you wanted to be complete, you would have the normal Swing and listeners running in the main (and of course event thread), the "panel" class in another thread (using invokeLater, or invokeAndWait to display the changes), and the "data" class in a third thread, with a synced queue between the listeners and the "data", and use wait/notify between the "data" and the "panel" classes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If I was on chapter 7 of SCJP study guide I would have answered correctly ;) , but I'm only chapter 3 :$

Technically, you were correct, and, in fact, that way may even be quicker than using the Collections manner, it's just longer to write, and not quite as "code reusable". ;)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I am sorry. Which collection class has sort method?

Collections

That is a Class in and of itself, much like Arrays.

kvprajapati commented: Great eyes! +3
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, as long as it's not JME implementing Comparable or creating a Comparator is the way to go, but there is no reason to use Arrays. Collections also has sort methods. No reason to convert to an array and back to a list, leave it as a list.