Query a database a show the results into a form
Hello!
I have a general question.
I have created a form and when the user submit it , it calls a servlet that store the information into a database.
Now I want to make a new page where you can look for the information that the user stored in to the database (according to an ID ) and that information must be showed to the user again into a form (same form but with two or more empty fields that he can update now).
What is the best way do that?
Should I include in the query.jsp a bean and program all in the bean and then come back with the results to the query page?
Im quite new to jsp, java...so , please I need your opinion about the best way to program that...
thanks in advance
As promised, here's a way to execute a SQL command and see the results in a JSP. It'll work with all four CRUD operations, as long as you pass valid SQL:
<%@ page errorPage="error.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<form name="sqlQueryTester" method="post" action="sqlQueryTester.jsp">
<center>
<h3>SQL Query Tester</h3>
<table>
<tr>
<th>SQL Query:</th>
<td>
<textarea name="sqlQuery" rows="10" cols="80"></textarea>
</td>
</tr>
</table>
<table>
<tr>
<td>
<input type="submit" name="submit" value="Submit"/>
</td>
<td>
<input type="reset"/>
</td>
</tr>
</table>
<c:if test="${not empty param.sqlQuery}">
<sql:query var="queryResult" sql="${param.sqlQuery}"/>
<hr />
<h3>Query Results</h3>
<c:forEach items="${queryResult.rowsByIndex}" var="row" varStatus="status">
<c:if test="${status.first}">
<table border="1" align="center" width="100%">
<tr bgcolor="#ffad00">
<c:forEach items="${queryResult.columnNames}" var="col">
<th><c:out value="${col}"/></th>
</c:forEach>
</tr>
</c:if>
<tr>
<c:forEach items="${row}" var="value">
<td><c:out value="${value}"/></td>
</c:forEach>
</tr>
<c:if test="${status.last}">
</table>
</c:if>
</c:forEach>
</c:if>
</center>
</form>I'll leave the web.xml and error.jsp as an exercise for you.
This will run on Tomcat 4.1.x and JSTL version 1.0.
%
Similar Messages
-
Hi,
I have a query that joins two tables in the same database, the result needs to be loaded in a destination DB table. How do I do this in SSIS package?
thank you !
Thank You Warmest Fanny PiedPlease take a look at these links related to your query.
http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database -
Why this query does not show the result?
Why the query with the schema prefixed does not show the result and the query without schema display the correct results?
SQL> select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS';
select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS'
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select data_object_id,object_type from dba_objects where object_name='HR.JOBS';
no rows selected
SQL> select data_object_id, OWNER, object_type from dba_objects where object_name='JOBS';
DATA_OBJECT_ID OWNER OBJECT_TYPE
69662 HR TABLE
OE SYNONYM
SQL> SELECT USER FROM DUAL;
USER
SYSHi,
the column object_name refers to a object_name which is 'JOBS', the column owner refers to the owner 'HR', the value isn't stored together, so you have to select the two columns. It is the same behaviour as every other table/view. Have a look at the values in the view DBA_OBJECTS.
Herald ten Dam
Superconsult.nl -
How To Make Search Query Showing the Result As List of Buttons.
Can some one give me an idea how to start to make a Search Query showing the results as list of buttons.. i have already have my buttons with names. i just dont know how to make a search query.
this is my on screen keyboard i made..
im making a system that the result were a list of buttons.. showing like this
This was supposed to be the output of the query that i need to do..
Please help me.. i just need a idea or tips how to make this one.Here is code I posted recently for another question
Public Class Form1
Const BUTTON_SIZE As Integer = 20
Const SPACE As Integer = 5
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim buttons As New List(Of List(Of MyRadioButton))
For row = 1 To 6
Dim newRow As New List(Of MyRadioButton)
buttons.Add(newRow)
For col = 1 To 6
Dim button As New MyRadioButton()
button.row = row
button.col = col
button.Height = BUTTON_SIZE
button.Width = BUTTON_SIZE
button.Left = col * (BUTTON_SIZE + SPACE)
button.Top = row * (BUTTON_SIZE + SPACE)
button.Name = String.Format("radGr1{0}_{1}", row.ToString(), col.ToString())
Me.Controls.Add(button)
newRow.Add(button)
AddHandler button.CheckedChanged, AddressOf Radio_Change
Next col
Next row
End Sub
Private Sub Radio_Change(ByVal sender As Object, ByVal e As System.EventArgs)
Dim button As MyRadioButton = CType(sender, MyRadioButton)
Dim row As Integer = button.row
Dim col As Integer = button.col
End Sub
End Class
Public Class MyRadioButton
Inherits RadioButton
Public row As Integer
Public col As Integer
End Class
jdweng -
Show the result of execution of a database procedure
Hi everyone,
I want to execute an oracle database procedure in oracle forms environment and show the result of execution to user(as "procedure executed successfully".. etc) How can I achieve this ?
Thanks..That would depend on the implementation of your procedure. I would say if there is no exception thrown then the procedure completed successfully. Of course there might be some additional conditions when you consider your procedure run successful.
So in the end you have to design your procedure so the caller can recognize if the procedure run successful or not. How you want to do this is up to you; you can use user defined exceptions (raise_application_error) if an error in your logic occurs which is not a default oracle exceptions, functions which return booleans or output stati.
I for one prefer exceptions, as they force the caller to handle them (I add the user-defined exceptions thrown by each procedure in the specification right to the documentation so the one using my procedure sees it right away) and ensure my procedure is atomic.
But as said this is entirely up to you.
cheers -
Execute a VO '4' times and show the result in single table at once.
Hi,
I want to execute single a VO query multiple times with different parameters and show the results together in a Table at once
In Detail
I have a table to which is associated with a VO.
The VO contains SQL whose WhereClauseParameters need to be dynamically binded.say headerId and lineId
Select ... from ....where headerId = :1 AND lineId = :2
I have to pass these 4 values and show all the results in a single table
headerId lineid
H1 ............... L1
H1 ............... L2
H2 ............... L1
H2 ............... L2
I understand that i need to bind parameters dynamically and exceute the VO.
As i have 4 different set of parameters, the view object will be executed 4 times.
I want to show all the results together in a single table.
How can I do it.
thanks,
GowtamHi Mani,
Thanks a lot for the patience and detailed solution.I will try it out and tell you the status.
Meanwhile, I have 2 questions on this solution(just curious)
I will give you the snapshot of the table
Table - ModelInfo
Model......Tube..... Float....Size......Col5.....Col6.......Col7.......
M1............T1.......... F1. .....1..........C15......C16.....C17.....
M1............T1...........F1.......2..........C25......C26.....C27.....
M1............T2......... .F2.......1..........C35......C36.....C37.....
M1............T2...........F2.......2..........C45......C46.....C47.....
M2............T1.......... F1. .....1..........
M2.............T1..........F1.....2.........Cn5.......Cn6........Cn7
.<continues...>
.<till>
.Mn............Tn..........Fn.......n........Cxy.......Cpq.......Crs....
Question 1:
if you notice this data,
The Columns 5 to 7 are dependent on Combination of Model,Tube,Float and Size.
Hence will this query work properly(without mixing up data from other Pk combination) and will it be efficient?(I Know this is a stupid qst, still double checking..As your solution assumes that each row is unique for Model only..which is not true)
Select ...From....Where
Model in(M1,M2,..Mn) AND Tube in(T1,T2..Tn) AND Float in(F1,F2,....Fn) and Size in(1,2...n).
In short, will C15,C16 and C17 appear only with M1,T1,F1,1..I believe it will.
Question 2:
As I told,
Third party program will return Array of Objects.
Each object will have a variable called Flow along with
Model,Tube,Float and Size.
Flow is not stored in the database(can not be stored due to functional reasons).I want to show this Flow also along with other columns fetched from the DB for all 100+ rows.
How can I do it?
I will give u the scenario(with just 2 rows)...please check(Flow is not stored in DB)
Third Party object : ObjModel
Model......Tube..... Float....Size......Flow
M1............T1.......... F1. .....1..........100
M1............T1...........F2.......2...........200.
M1............T2.......... F1.......1..........300
M1............T2...........F2.......2..........400
My concern is,
After the VO executes and shows other 6 columns, it should show Flow appropriately.(associated with each object in the array)
I understand that I need to have a Transient attribute in VO called[b] Flow.But I don't know how to perform the two tasks simultaneously..
Task1:Your solution on showing table columns
Task2:Showing Transient data for each object returned from program.
thanks,
Gowtam -
The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
pear to be working or at least I am not getting any indication on the inidcator.
Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
Attachments:
regulation_tester_7_loops.vi 244 KBI didn't really have time to dig in and understand your program in depth,
but I have a few tips for you that might things a bit easier:
- You use local variables excessively which really complicates things. Try
not to use them and it will make your life easier.
- If you flowchart the design (very similar to a dataflow diagram, keep in
mind!) you want to gather data, calculate a value from that data, store the
calculation in an array, and loop while the time is in a certain range. So
theres really not much need for a sequence as long as you get rid of the
local variables (sequences also complicate things)
- You loop again if timepassed+1 is still less than some constant. Rather
than messing with locals it seems so much easier to use a shiftregister (if
absolutely necessary) or in this case base it upon the number of iterations
of the loop. In this case it looks like "time passed" is the same thing as
the number of loop iterations, but I didn't check closely. There's an i
terminal in your whileloop to read for the number of iterations.
- After having simplified your design by eliminating unnecessary sequence
and local variables, you should be able to draw out the labview diagram.
Don't try to use the "insert into array" vis since theres no need. Each
iteration of your loop calculates a number which goes into the next position
of the array right? Pass your result outside the loop, and enable indexing
on the terminal so Labview automatically generates the array for you. If
your calculation is a function of previous data, then use a shift register
to keep previous values around.
I wish you luck. Post again if you have any questions. Without a more
detailed understanding of your task at hand it's kind of hard to post actual
code suggestions for you.
-joey
"nelsons" wrote in message
news:[email protected]...
> how do I create a 1d array that takes a single calculation and insert
> the result into the first row and then the next calculation the next
> time the loop passes that point and puts the results in thsecond row
> and so on until the loop is exited.
>
> The attached file is work inprogress, with some dummy data sp that I
> can test it out without having to connect to equipment.
> The second tab is the one that I am having the problem with. the
> output array from the replace element appears to be starting at the
> index position of 1 rather than 0 but that is ok it is still show that
> the new data is placed in incrementing element locations. However the
> main array that I am trying to build that is suppose to take each new
> calculation and place it in the next index(row) does not appear to be
> working or at least I am not getting any indication on the inidcator.
>
> Basically what I am attempting to do is is gather some pulses from
> adevice for a minute, place the results for a calculation, so that it
> displays then do the same again the next minute, but put these result
> in the next row and so on until the specifiied time has expired and
> the loop exits. I need to have all results displayed and keep building
> the array(display until, the end of the test)Eventually I will have to
> include a min max section that displays the min and max values
> calculated, but that should be easy with the min max function.Actually
> I thought this should have been easy but, I gues I can not see the
> forest through the trees. Can any one help to slear this up for me. -
Search in Nested Tables and Insert the result into new Nested Table!
How can I search in Nested Tables ex: (pr_travel_date_range,pr_bo_arr) using the SQL below and insert the result into a new Nested Table: ex:g_splited_range_arr.
Here are the DDL and DML SQLs;
Don't worry about the NUMBER( 8 )
CREATE OR REPLACE TYPE DATE_RANGE IS OBJECT ( start_date NUMBER( 8 ), end_date NUMBER( 8 ) );
CREATE OR REPLACE TYPE DATE_RANGE_ARR IS TABLE OF DATE_RANGE;
DECLARE
g_splited_range_arr DATE_RANGE_ARR := DATE_RANGE_ARR( );
g_travel_range DATE_RANGE := DATE_RANGE( '20110101', '99991231' );
g_bo_arr DATE_RANGE_ARR := DATE_RANGE_ARR( DATE_RANGE( '20110312', '20110317' ), DATE_RANGE( '20110315', '20110329' ) );
FUNCTION split_date_sql( pr_travel_date_range DATE_RANGE,
pr_bo_arr DATE_RANGE_ARR )
RETURN DATE_RANGE_ARR
IS
l_splited_range_arr DATE_RANGE_ARR;
BEGIN
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM (WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT tr_end_date, 0 FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT bo_start_date - 1, 1 FROM TABLE( pr_bo_arr )
UNION ALL
SELECT bo_end_date + 1, -1 FROM TABLE( pr_bo_arr )),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val) AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val) AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date);
RETURN l_splited_range_arr;
END;
BEGIN
g_splited_range_arr := split_date_sql(g_travel_range,g_bo_arr);
FOR index_g_splited_range_arr IN g_splited_range_arr .FIRST .. g_splited_range_arr .LAST LOOP
DBMS_OUTPUT.PUT_LINE('g_splited_range_arr[' || index_g_splited_range_arr || ']: ' || g_splited_range_arr(index_g_splited_range_arr).start_date || '-' || g_splited_range_arr(index_g_splited_range_arr).end_date );
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
NULL;
END;Or can I create a VIEW with parameters of Nested Tables in it so I can simply call
SELECT *
BULK COLLECT INTO g_splited_range_arr
FROM view_split_date(g_travel_range,g_bo_arr);@riedelme
For your questions:
1) I don't want to store in the database as a nested table
2) I don't want to retrieve data from the database. Data will come from function split_date() parameter and data will be processed in the function and function will return it in nested table format. For more detail please look at the raw function SQL.
I have a SQL like:
WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM travel
UNION ALL
SELECT tr_end_date, 0 FROM travel
UNION ALL
SELECT bo_start_date - 1, 1 FROM black_out_dates
UNION ALL
SELECT bo_end_date + 1, -1 FROM black_out_dates),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val)
AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val)
AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date;I want to change the tables black_out_dates and travel to Nested Array so I can use it in a function with Nested Array travel and Nested Array black_out_dates parameters and the function will return Nested Array of date ranges.
Here is what I want in raw SQL:
DECLARE
g_splited_range_arr DATE_RANGE_ARR := DATE_RANGE_ARR( );
g_travel_range DATE_RANGE := DATE_RANGE( '20110101', '99991231' );
g_bo_arr DATE_RANGE_ARR := DATE_RANGE_ARR( DATE_RANGE( '20110312', '20110317' ), DATE_RANGE( '20110315', '20110329' ) );
FUNCTION split_date_sql( pr_travel_date_range DATE_RANGE,
pr_bo_arr DATE_RANGE_ARR )
RETURN DATE_RANGE_ARR
IS
l_splited_range_arr DATE_RANGE_ARR;
BEGIN
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM (WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT tr_end_date, 0 FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT bo_start_date - 1, 1 FROM TABLE( pr_bo_arr )
UNION ALL
SELECT bo_end_date + 1, -1 FROM TABLE( pr_bo_arr )),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val) AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val) AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date);
RETURN l_splited_range_arr;
END;
BEGIN
g_splited_range_arr := split_date_sql(g_travel_range,g_bo_arr);
FOR index_g_splited_range_arr IN g_splited_range_arr .FIRST .. g_splited_range_arr .LAST LOOP
DBMS_OUTPUT.PUT_LINE('g_splited_range_arr[' || index_g_splited_range_arr || ']: ' || g_splited_range_arr(index_g_splited_range_arr).start_date || '-' || g_splited_range_arr(index_g_splited_range_arr).end_date );
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
NULL;
END;I must change the tables black_out_dates and travel in a way so it will be something like
FROM TABLE( pr_travel_date_range )to get the result into l_splited_range_arr so it will be something like
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM ( -
In the Alarm & Event Query VI how to show the alarm data
In the Alarm & Event Query VI how to show the alarm data in the front pannel using the table or multicolumn listbox .thank you very much!!!
Hi,
Most likely there is something wrong with your specific database or your LabVIEW DSC installation. I just used the Alarm & Event Query.vi in my machine and it seems to work fine, I can see all the alarms as well as events containned in the database.
You may considerer generate another database (change the logging directory) and see if the behavior goes away. Also, make sure you have alarms and events on that database.
I could run the Alarm & Query.vi by just openning its front panel and placing the correct database in the appropriated control. -
Showing the results window after termination
Hi all,
When I terminate my batch sequence execution in TS 4.0 using "RunState.Engine.TerminateAll()", it shows grayed-out windows and won't show the results window, even though it saves the results into an XML file on disk.
Is there a way I can show the results window to the operator after the sequence is terminated?
Many thanks,
Chris
Solved!
Go to Solution.If you look in your model you will find a step called Read Entire Report. This is just making an activex call to Report.Load. This is what displays the report at the end of an execution. If this does not get called no report will get loaded. Since you are terminating then no report is getting loaded. In fact if you don't have on the fly reporting on then the html files that make up each thread of a multithreaded batch run won't contain any data which will result in no report.
If you use the ProcessCleanup callback you should be able to load the report in there.
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
My ios update keeps getting stuck on the Restoring iPhone software stage. I uninstalled iTunes and reinstalled it again, but still nothing. Now I can't even use my phone as it shows the plug into iTunes screen. Please help!!!! Thanks,
A Restore first downloads a new copy of iOS to your computer. On a slow Internet connection this can take a long time. How fast is your connection? How long would you expect it to take to download 900 MB?
That's assuming nothing is interfering with the download. Some firewalls and antivirus programs will block the download or slow it down. So you should temporarily disable your security software. Security software can also block the update after the iOS download is complete. -
How can show the result of a measuring that is done in a sub-program in my main panel?
How can show the result of a measuring that is done in a sub-program in my main panel?
In your subvi, wire the result(s) you want to ouput to the main program to an output terminal on the connector pane.
For a tutorial on subvi's, search the help for "connector panes" anc click on tutorial.
~Tim -
I connect my iphone 4 to the itune. It asked me to download a new update for my phone. After I downloaded the update, the itune no longer able to detect my iphone through the USB. My phone is un-responsive showing the plug into the itune icon only on the screen. Please help.
http://support.apple.com/kb/HT1808
-
when we type a search item in firefox on my laptop then it shows the result then on second or third or more new search that is typing a new search it sticks to the first searched one
Tried that. Also tried SUPERAntiSpyware, ccleaner, HitmanPro. Removed anything that was reported. Problem persists.
Chrome is also affected. But couldn't find any alternative way of not having Ask.com loaded as did in Firefox.
Internet Explorer was initially affected. After the Ask.com search engine is removed that problem appears to have gone away.
12/9/2014
Interestingly, yesterday afternoon the Chrome browner new tab no longer hijacked by Ask.com. The symptom was there in the morning and had gone away in the late afternoon. Nothing was done except a few days ago I blocked everything on that page. The problem with Firefox continue to persist I didn't do the same blocking on it. I am going to try the same and then use anti-spyware to clear away all cookies and see what happens. -
How to use TextField to add two numbers and show the result.
hi everybody
i would like to use JTextField to get addtion of two Numbers,
for example i am trying to type any integer numbers in JTextField like 7
and press JButton, called( +) to add anthor number like 7 and press JButton called(=) to get addtion fo
7 + 7 = 14, at same JTextField.
so there will be two buttons, one for (+),other for (=).
i have implement ActionListener in (+) button ,to get Text from JTextField (with getText() method),
now how do i use same getText() method to get the next number that i will add it with previous number in
(+) button and get the result whenever i press (=).
1-type integer number like (4) in TextField.
2-press addition button(+) to get text by using getText() method and clear TextField.
3-type anthor integer number like(6).
4-press (=) button to get the number (6) by using getText() method, calculate 4 + 6 and show the result at same TextField (10).
i hope it is so clear
thank u in advance for any advice and suggestion.Use your first button to
String x = JTField.getText();
int y = Integer.parseInt(x);
this will get your first value on your + button. Make sure you initialise the int beforehand incase nothing is put in (ie error prevention) then clear the JTField prob using setText(""). Repeat the process for the = button using different variables and add them normally and output the result.
If your putting more than 1 arithmetic button on the GUI then you'll need to distinguish between them!!!
Maybe you are looking for
-
Sold my Logic 9 - Do I just need to delete from my MB Pro?
I've sold my version of Logic Pro Studio 9 and want to make sure the purchaser has no problems. Do I just need to delete from my macbook pro of is there anything else I need to do? I cant see how to deregister. Hard times so had to sell sadly. Any ad
-
hi i have a class "Club" it contains an ArrayList, add and remove methods and a method to retrieve player details. (The code for class Club is provided below). i want to write a new class called Main which prints out the information held about each p
-
I tunes wont let me update without 10.7.5
-
Printing/crashing issues with Office 2004 after 10.5.3 upgrade.
I have an iMac on 10.5.3 and whenever I try to print Word, Excel, or PPT, the apps crash. Just recently the apps are crashing just when I attempt to open up a document. I thought it was the fact that I use Carbon Copy Cloner and have a clone of these
-
We are looking on a solution where we can archive data based on criteria, we have 10 different table referencing and we proposed if any row marked for archival using some indicator should also mark all other related to row for archiving. However it m