Brendan Cregan

Ranch Hand
+ Follow
since Nov 11, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brendan Cregan

Hi,

I have been trying to mess around with Java 3D, in particular the 3D sound engine, I found this example code for a SimpleSounds Applet and im getting compiling errors with the example code, I was just wondering does anyone have any experience with this example and how to get it working?

So the error is

Exception in thread "main" java.lang.NullPointerException: Canvas3D: null GraphicsConfiguration
at javax.media.j3d.Canvas3D.checkForValidGraphicsConfig(Canvas3D.java:963)
at javax.media.j3d.Canvas3D.<init>(Canvas3D.java:1006)
at SimpleSounds.<init>(SimpleSounds.java:47)
at SimpleSounds.main(SimpleSounds.java:249)



And the example code is



Thanks in advance for any help with this issue!

Brendan
8 years ago
Hi All,


I have made a quiz servlet program and here I am trying to check if a user is there, then check their previous score, the else statement is working to create a new user in the DB if no score is present.
I'm convinced it has something to do with my syntax, but can't figure out what it is, as I have similar Queries at other sections of my servlet that are working fine.



Thanks for any help,

Brendan

Paul Clapham wrote:It isn't the loop which is the problem. The problem is that you declared the answerRow variable inside the loop, thus restricting its scope so that it is only visible to code inside the loop. Since you want it to be visible outside the loop, then you have to declare it outside the loop.

Don't confuse declaring the variable (int answerRow) with assigning a value to it (answerRow = answerID.getInt(1)). You can do those two things separately, and in this case you should. Declare the variable outside (before) the loop, assign it the value inside the loop.



thanks , I did understand the problem, but didnt know that declaring it ouside the loop was the solution!
Thanks Paul!

Brendan

Wendy Gibbons wrote:resultset.next() tells you if there are any more rows in the result set.
Remember a result set can contain many columns for a single row, and lots of rows.

.
this page has a full example of how to use result sets.

http://docs.oracle.com/javase/tutorial/jdbc/basics/retrieving.html



thanks Wendy, i have implemented this


but the problem is i need to read the value outside of the while loop, is there any other way to implement the answerRow.getInt() without the while()?

Thanks

Brendan
Hi All,

Im working with a small database for a simple enough quiz servlet program, i have the db working ok, it just prints out questions, im also using the DB to store the row of a random questions so that i can look up the correct answers between servlet instances.(this could be the complete wrong way to approach the problem, but it seems to work ok).my only problem is when i try to retrieve the row of the answer, im using microsoft access and i can see from the access program that its storing the correct question row as an int, but when i try to retrieve it im getting an error saying its a boolean which seems unusual since its storing correctly in the database.

this is from my checkAnswer servlet where im attempting to retrieve the answerRow, and its giving an invalid type of boolean.


any help would be much appreciated!

Go Raibh Maith Agat!


Bear Bibeault wrote:

Brendan Cregan wrote:i was confused with the assignment since it worked for !=


That's not an assignment, that's just another of the comparison operators: == != <= >=

The = operator is assignment, not comparison.



Thanks for clearing that up for me Bear!and thanks for the help!
9 years ago

Manish Sridharan wrote:Hi,

In the below code you are not comparing the value of the variable instead assigning value of the answer variable to the variable myChoice.


Thanks,



Thanks Manish, i was confused with the assignment since it worked for !=

Brendan
9 years ago

You did fix your assignment syntax error, right?

i pressume this means that I am a complete fool for whatever error i have made!putting it in bold just makes your wisdom even more useful!
9 years ago

Bear Bibeault wrote:If you had added debug statements like I hinted at, you would have found the assignment error noted above.

A couple of other points:

  • Your form is generating a GET. A doPost() will not be called unless you specifically call it from doGet() (which is bad paractice). Match the method to the form.
  • Never re-invent the wheel. Look on the Boolean class to see if there's a conversion that you can use instread of writing your own.
  • Once you find the above, it will tell whether 0 and 1 are good choice for the values.


  • Thanks bear, but im only learning, so i wouldnt be to good on the uptake of hints!I did look into the boolean conversion but it appeared as far as I could tell that I had to make the conversion myself.
    What do you men by debug statements? what i did was just added a print out of values so on submission i was getting
    "Congratulations, you answered "true" and the answer was "true" so you are correct" in both instances.and I am still completley baffled by the result

    Thanks

    Brendan
    9 years ago
    and heres my conversion of 0 & 1 to a boolean incase i made a mess of it :'(

    9 years ago
    one more weird thing i noticed is that in the address bar it seems to be working ok...
    http://localhost:8080/quiz/checkanswer?radiochoice=1 for true and http://localhost:8080/quiz/checkanswer?radiochoice=0 for false...would my problems stem from my choice of doPost?


    Thanks
    9 years ago
    ok, so i ran a little test and it turns out the servlet keeps thinking im answering true and doesnt ever seem to pick up when i pick false, I know it has something to do with the radio buttons...

    in particular these lines, is the value 0 & 1 acceptable?i am converting them to boolean....


    Thanks again


    Brendan
    9 years ago
    in the spec we are only able to use servlets...its going wrong when i submit my answer, it always says that it is the correct answer, i have a feeling it has something to do with my radio buttons but im not really sure as im not very familiar with HTML.


    Thanks

    Brendan
    9 years ago
    Hi,

    Im working on a quiz servlet, where a question is retrieved from a database and then the user must choose true or false, I have to implement it with radio buttons but I'm having difficulty getting the buttons to display the correct response.It just seems to always say that the answer is correct.Here is some of the code that should illustrate the problem a bit better.

    Here is the form part of my main servlet, which sends the data to a checkanswer servlet


    and here is my handeling of the form in check answer


    Any help with this would be much appreciated....

    Brendan
    9 years ago