javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The correct is:
import java.util.Scanner;

not:
import.java.util.Scanner;

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First this could be helpful:

select count(*), col_1, col_2 
from myDatabase

Each "row" of the ResultSet will have the row count as well as the columns.

Also you can run 2 queries.
The first that will get you the row count
The second that will get you the columns


But the above suggestions aren't very good.


IF you want both the row count and the columns, I assume that you want the row count to create an array and then put inside the array the data from the table. Since you are using an array you need to know exactly how many rows will be returned before creating it. Right?

If that is the case, use the java.util.Vector. It has methods for adding and getting elements. It doesn't have a fixed size like the array. You can keep adding elements to it without knowing the number of rows the query returned

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hi guys, how can I retrieve the total record count from a database? I mean is there a method like "rst.recordCount"? or whatsoever? thanks...

If you run this query at an SQL editor:

select count(*)
from your_table

It will get you the number of rows that table has.
In general the count() method "returns" the number of rows that the query would return.
So if you run the above query through java and do something like this:

ResultSet rs = null;
...
...
...

int count = rs.getInt(1);

The query return only 1 column (count(*)) so you need to call:
rs.getInt(1)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all I don't get that problem. What type of computer are you using? (RAM, processor ?)

Also I used to have JCreator, if you want to try it.
Another IDE is the oracle's JDeveloper but personally, I don't like it very much

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

System.out.println()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That you want in the way you want it cannot be done.
If you want to call a java method, after the page has rendered, by clicking a button you need to submit the form, to a servlet or jsp (preferably a servlet) and there you can call your java method. Then you must redirect to whatever page you want with the results.

Check the first Read Me post of the jsp forum about MVC:

"JSP database connectivity according to Model View Controller (MVC) Model 2"

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all if you want the initial data to be displayed then maybe you can do something like this:

if(request.getParameter("distselect")!=null && issubmitted!=true) {
   //sm stuff
}
//else -- remove the else
//my initial data

About the default value at the "select" check this link:

http://www.w3schools.com/tags/att_option_selected.asp

Remember only 1 option can have the "selected" attribute and if more than one have it the default value will the last option that had it.

And I believe that I mentioned that site. Maybe you should read its tutorials because they helped me a lot

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hey y don't u try the simplest way out:

Arrays.sort(testarray);

for(int i =0; i<length; i++)
System.out.println("Sorted Array values: " + testarray);

System.out.println("Minimum Value: " + testarray[0]);
System.out.println("Maximum value: " + testarray[length-1]);

what do u think using "Arrays.sort()" to sort ur array in accsending order and fill ur requirement...

This is a 17 month old thread and the idea is to learn how to find the max number of an array! To implement the algorithm for homework!

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If I understood correctly you want the user to enter characters?
Then you already have the code:

option=stdin.readLine();

All you have to do is check the "option":

if (option.equalsIgnoreCase("M")) {

}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What's inside the "else" should be displayed.
Have you tried to see the value of the request?

<%
String Distselect = request.getParameter("Distselect");
System.out.println("Distselect is: "+Distselect);

if (Distselect==null) {
  System.out.println("Inside If");
%>
   IFIFIFIFIFIFIFIF
<%
} else {
  System.out.println("Inside If");
%>
   ELSEELSEELSE
<%
}
%>

Just try only this and see what happens.
Also you could post some more code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all what do you mean by custom tag?
Second, I believe that they should behave the same, whether it is clicked with a mouse or by pressing <Enter>. If I am wrong someone please correct me.
And third, is it possible to see some code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all you will need javascript: http://www.w3schools.com/default.asp

There is the onchange function. You can have the form submit there:

<form name="formName" action="">

<select name="param" onchange="document.formName.submit()">
...
</select>

</form>

Then at the beginning of your jsp:

<%

String param = request.getParameter("param");
if (param!=null) {
   // form was submitted
} // if param is null then you just browse to this page without submitting

%>

If you need to read data from database, I would suggest to submit to a Servlet, read the data and come back to the jsp page. There is a tutorial at the beginning of the jsp forum about MVC which you might want to read

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all, I don't think it is a good idea to put at the session the password.
Second if you need more than one users then:

session.setAttribute("user_1",request.getParameter("name"));
...
session.setAttribute("user_2",request.getParameter("name"));
...

session.setAttribute("user_"+counter,request.getParameter("name"));
counter++;

The counter could be an int variable also stored in session. Every time a user logs in put his name in the session and increase the counter. Of course you must be careful because if you have session timeout then the counter will become null when you get it from the session. So you need to check that and if it is null set it to 0 again. Besides if that happens then all the users that were logged in will get a timeout so you want miss a thing. They will have to loggin again.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to call a java method you need to go to the server, so you need to submit.
The "select" part must be inside the form otherwise the what you have selected will not be send at the request.

Just replace this call:
onchange = "distdisplay()"
with the one that submits the form.

Then take the value of what was selected and do your thing:

request,getParameter("Distselect")

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When the onchange method is called you can submit the form to a servlet. Then read the data and come back to the jsp.
Read the first post at the jsp forum for more details on how to connecti jsp and servlet with database

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Post code.
Read API of JOptionPane

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is not the same code you had at your previous thread. Why did you changed it?

Also why are you checking this:
if(c < 'C')
BEFORE you call this:
c = c - (key % 26)

Also why are you using this character: 'C'. I already explained what you should put there

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Make sure Eclipse "Window/Preferences/Java/Compiler/Compiler compliance settings" is set for 6.0 and reload Eclipse.
--Vic

You are more than 1 year late when the problem has been solved.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can also check this:

java.lang.NullPointerException
at parts.OraclePlm.main(OraclePlm.java:83)

At line 83 something is null

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Read this:
JSP database connectivity according to Model View Controller (MVC) Model 2

Also for creating a link, try this:

String url = "http://www.daniweb.com";
....
<a href="<%= url%>">Click here</a>

or

String url = "http://www.daniweb.com";
String value = "Dani Web Forum";
....
<a href="<%= url%>">
   <%= value %>
</a>
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Meaning put some value to a field and then push something so that this value would be put to a java variable?

Yes, submit the page.

When you see the JSP page, java code has already been executed. If you want to execute some more you need to go to the server by submitting.
If you have java code in a jsp page, that code is first executed at the server and then page is displayed.
So when you submit, the code that gets executed (getting values from the request) is at the server. When this is done, you see the page

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because: "C:/Users/Solris/Desktop" is NOT a file. It is a Directory.
Shouldn't you do something like this: File f = new File("C:/Users/Solris/Desktop/file.txt");

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you have a value in a textfield and want to put it in a java variable, you need to submit the form (or pass it as parameter at a hyperlink)

If you want to put a java variable to a textfield, when you go to the page you need to take it from the request and put it to the field when the page renders.

Remember first the code executes at the server and then the page is loaded. So you take the value from the request and then the field with the value will be displayed:

String something =  (String)request.getAttribute("key");
...
<input type="text" name="someName" value="<%= something %>" />
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And then and MOST IMPORTANT do whatever you want to do from the beginning but this time follow the tutorial at the top of the JSP forum with title JSP database connectivity according to Model View Controller (MVC) Model 2

Now you must follow the link above and start all over

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

First of all, osiris003 you are wrong.
Second kuay you had a thread started, I posted an answer, you asked another question and then started a new one with same question. I already gave you an answer to your first thread but now I need to answer again in this new one. Why did you created a new thread with same question? That will get you a bad rep from me
As for the answer:
You are correctly subtracting the key instead of adding but:

Before:

c = c + (key % 26);
if (c > 'Z')
c = c - 26;
}

After:

c = c - (key % 26);
                if (c > 'Z')
                {
                    c = c - 26;
                }

Since you are subtracting, shouldn't change these as well: if (c > 'Z') and c = c - 26; Remember now you are subtracting so there is chance you will go "below" 'A'

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't know if this the case, but you MUST first call: rs.next() to get the row from the ResultSet.
Meaning that when you do: String Instructor = rst.getString("Instructor"); you probably get an exception, go inside catch, and nothing is displayed:
Also about this:

if (Instructor == null) 
    Sorry, no match for that user in our database. Please try again.

If there is no match the rs.next() will return false. So you need an if statement checking that. If it is false, THEN there is no match. If there is no match then the rs.next() will be false not the Instructor null. If you manage to call rs.next() and the rst.getString("Instructor") then there was a row returned so there are values to retrieve.
When Instructor is null doesn't mean that there were no rows. It means that you got a row from the database and the table column with name "Instructor" doesn't have a value. Of course if "Instructor" is Primary Key that would be impossible but I am talking in general.

So I suggest, first put some message inside the catch that are printed at the page:

catch (ClassNotFoundException e) {
            System.err.println("Could not load database Driver!");
%> <%= e.getMessage()%> <%
        } catch (SQLException e) {
            System.err.println("Could not connect to to the database!");
%> <%= e.getMessage()%> <%
        }

And then and MOST IMPORTANT do whatever you want to do from the beginning but this time follow the tutorial at the top of the JSP forum with …

CodeBoy101 commented: This guy is one of the best reasons to come to Daniweb!! +2
VernonDozier commented: Good advice. +16
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to use java it must be done at the server. Meaning before you render the page.
For example.
Put a value at the request request.setAttribute("key","The Value") Then submit, redirect or whatever and at jsp, get it and put it at the field:

String something =  (String)request.getAttribute("key");
...

<input type="text" name="someName" value="<%= something %>" />
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can you post again the new code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Let's take the first word: "NS" and the letter 'N'
The alphabet goes:
"N", "O", "P", "Q", "R", "S"

You program returns: "SX": 'S'

As you can see if you add 5 to 'N' at the sequence I gave you (N, O, P, Q, R, S) the 5th letter after 'N' is 'S'. So program correctly returns: 'S' (SX)

But if you have subtracted 5:
"I", "J", "K", "L", "M", "N"
from 'N' you would have received the letter 'I' (IN)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If I understand correctly (if I don't you should have provided a better explanation) you want to insert a new order in a database?
If yes there is an SQL command when you create a table where you set the Primary Key to be auto increment so when a new row is inserted the key will have a sequence number. Try to search how to create a "sequence" and how to get the next value at an SQL forum or at the internet.
If you want the String "GB" next to the number, then create the table like normal with a primary key, then declare the "sequence" and whenever you want to insert write a select that gets the next number and add to it the String "GB". Then use this value as order ID.

Of course everything is based on assuming that this was what you wanted to know. If I am wrong provide better explanation.
If I was right but you don't understand what I am saying it's my fault. Ask for better explanation at an SQL forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you read the part of the stack trace I posted?:

An exception occurred processing JSP page /upload_page.jsp at line 22

22: saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+ 1,saveFile.indexOf("\""));

java.lang.StringIndexOutOfBoundsException: String index out of range: -83577
java.lang.String.substring(String.java:1938)

Perhaps you should test first in a separate main java file what you are trying to accomplish with saveFile.substring


Also I noticed that you connect to the database inside the jsp file. Don't do that. Use the tutorial that is at the top of the JSP forum with title ... MVC ...

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

LONG LIVE THE CHIPMUNKS. You will never silence the voice of freedom fighter (not terreorist) 'IndyBoy'!! :)

But seriously, who came up with this assignment???

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What is the full name of the file you are trying to compile?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Why don't you put everything in one jsp. When the user clicks Submit go to a servlet and delete the row.
Then you can either read again the data from the the database and display them or
You can have the previous data in List. Then whenever you submit or display the data you can have the List sent into the request with the "request.setAtttribute". If the delete is successful remove that data from the List and send it again at the request to be displayed

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually this is the second time I received such a message. The first was sent to my yahoo account and it very similar

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi everybody,
I hope that this is the right forum to post this.

I just received a rather strange PM from someone. They were asking me for my bank account number in order to deposit a great amount of money. The PM had an extensive story why they want my help in order to transfer the money into my account.

Now I didn't know where to report this so I found this forum which I thought was appropriate.

If some administrator is reading this, please provide me with instructions on how to proceed. By the way, I just noticed that the person who send me that PM has the flag "Banned" under his name.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can use whatever you want. Did you look at the API?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the API for DecimalFormat.
The error is because "format" doesn't exist as field variable. It says it clearly:
"can't find symbol" Meaning "format" doesn't exist.
Maybe you meant to call it as a method:
num.format() but I am not sure until YOU check the API

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use code tags.
If you can't use code tags don't just say the error is at line 5. Try to point out where the error is. What if the error was at line 100. Should we count 100 lines?
And the answer is this:
You wrote:

public SavingsAccount(double bal); //constructor
{
savingsBalance= b;
}

First of all "b" variable is not defined: savingsBalance= [B]b[/B] I believe you meant: savingsBalance= [B]bal[/B] which is the argument of the constructor.

Also you should remove the ';' after the declaration of the constructor: public SavingsAccount(double bal) [B];[/B] //constructor

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you look at this very obvious part of the exception:

......
org.apache.jasper.JasperException: An exception occurred processing JSP page /upload_page.jsp at line 22
......
22: saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+ 1,saveFile.indexOf("\""));
............
java.lang.StringIndexOutOfBoundsException: String index out of range: -83577
java.lang.String.substring(String.java:1938)

The reason why you get the error is quite clear

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is part of an example:

Navigation frame
How to make a navigation frame. The navigation frame contains a list of links with the second frame as the target. The file called "tryhtml_contents.htm" contains three links. The source code of the links:
<a href ="frame_a.htm" target ="showframe">Frame a</a><br>
<a href ="frame_b.htm" target ="showframe">Frame b</a><br>
<a href ="frame_c.htm" target ="showframe">Frame c</a>
The second frame will show the linked document.

Look at it at this page and click the link: Navigation frame for further details.

When you click the link: Frame a the new page will not open in a new window but only at the target which will be the frame you specify. Don't forget to give a "name" to each of your frames. Use the "name" attribute as shown at the example, at the link Navigation frame.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't run 2 queries; as proposed in previous posts you run ONE query where you make the comparisons with sql and return only the data you want.
Then you put the results in a List and send that List to a JSP where you display the data.
It is very bad idea to display data inside servlets.
Read the tutorial about MVC that is at the top of the JSP forum.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Threads merged

Finally, Good job

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Apart form Peter's suggestion I will like to add something.

First if you are reading the data in one jsp why aren't you displaying them in the jsp you are reading them? Or why don't you read the data at the jsp that the link takes you?

It makes no sense to read data in one jsp and then click a link in order to take you to another and display the data there.

One thought is that you probably read the request in the 1st jsp: String s = request.getParameter("something") that came from a "submit" button, and you don't know how to send the request to another jsp using a link.

If that is the case then: <a href="second.jsp?something=5&another=test">Click here</a> or

String s1 = "5";
String s2 = "test"
<a href="second.jsp?something=<%= s1%>&another=<%= s2%>">Click here</a>

At the other jsp you can do:

String s1 = request.getParameter("something"); // 5
String s2 = request.getParameter("another"); // test

Of course you must never connect to a database inside a jsp or do anything else apart from displaying data or sending data other JSPs or servlets.

So in your case the link should take you to a servlet, then read the database, then redirect using Peter's example to the jsp you want.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

1. a. Create a parent class "Vehicle" with one method "turnLeft" that prints "Vehicle turning left".
b. Create a child class "Bike" which overrides the "turnLeft" method and prints "Bike turning left".
c. Create a Vehicle reference referring to a Bike object. Is it legal? What happens when the "turnLeft" method is called through the Vehicle reference?

A vehicle that only turns left. That is scary. I don't want to be in the road with you driving:)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you don't get an answer soon don't start another thread asking the same thing. What did you expect? That the very first minute you posted everyone should give you the solution? Your impatience was very annoying, flooding the forum with new threads.
We are not here to serve your needs nor we are obligated to give you immediately the answer.
If you didn't get a reply then wait for someone who knows the answer to post. Posting and posting again will not change things.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And what is this suppose to be?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Welcome mc080201812.

Before you post anything you must read How to post your problem & source code?

Source code must be surrounded with BB code tags.

Your post must be moved to JSP forum.

So from what you have read, that was the problem with mc080201812's post. Not using code tags

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

. . . create new one in JSP section with full description of problem including any relevant coding

Exactly as I have instructed him when I replied to his PM