Needs help for tuning the sql
Hi
I have a query which will read one fact table and 4 dimension table.fact table contains millions of records
Can u suggest me how can i tune my query which uses the fact table to get the best performance.
Which version of the database are you using? Have you enabled Star Transformation? What does the explain plan look like? Is this intended for building a materilaized view or as the basis for running an ad hoc report?
We created bit map indexes on the joining columns.bitmap indexes or bitmap-join indexes?
Cheers, APC
Similar Messages
-
Need help for understanding the behaviour of these 2 queries....
Hi,
I need your help for understanding the behaviour of following two queries.
The requirement is to repeat the values of the column in a table random no of times.
Eg. A table xyz is like -
create table xyz as
select 'A' || rownum my_col
from all_objects
where rownum < 6;
my_col
A1
A2
A3
A4
A5
I want to repeat each of these values (A1, A2,...A5) multiple times - randomly decide. I have written the following query..
with x as (select my_col, trunc(dbms_random.value(1,6)) repeat from xyz),
y as (select level lvl from dual connect by level < 6)
select my_col, lvl
from x, y
where lvl <= repeat
order by my_col, lvl
It gives output like
my_col lvl
A1 1
A1 3
A1 5
A2 1
A2 3
A2 5
A3 1
A3 3
A3 5
A4 1
A4 3
A4 5
A5 1
A5 3
A5 5
Here in the output, I am not getting rows like
A1 2
A1 4
A2 2
A2 4
Also, it has generated the same set of records for all the values (A1, A2,...,A5).
Now, if I store the randomly-decided value in the table like ---
create table xyz as
select 'A' || rownum my_col, trunc(dbms_random.value(1,6)) repeat
from all_objects
where rownum < 6;
my_col repeat
A1 4
A2 1
A3 5
A4 2
A5 2
And then run the query,
with x as (select my_col, repeat from xyz),
y as (select level lvl from dual connect by level < 6)
select my_col, lvl
from x, y
where lvl <= repeat
order by my_col, lvl
I will get the output, exactly what I want ---
my_col ....lvl
A1 1
A1 2
A1 3
A1 4
A2 1
A3 1
A3 2
A3 3
A3 4
A3 5
A4 1
A4 2
A5 1
A5 2
Why the first approach do not generate such output?
How can I get such a result without storing the repeat values?If I've understood your requirement, the below will achieve it:
SQL> create table test(test varchar2(10));
Table created.
SQL> insert into test values('&test');
Enter value for test: bob
old 1: insert into test values('&test')
new 1: insert into test values('bob')
1 row created.
SQL> insert into test values('&test');
Enter value for test: terry
old 1: insert into test values('&test')
new 1: insert into test values('terry')
1 row created.
SQL> insert into test values('&test');
Enter value for test: steve
old 1: insert into test values('&test')
new 1: insert into test values('steve')
1 row created.
SQL> insert into test values('&test');
Enter value for test: roger
old 1: insert into test values('&test')
new 1: insert into test values('roger')
1 row created.
SQL> commit;
Commit complete.
SQL> select lpad(test,(ceil(dbms_random.value*10))*length(test),test) from test;
LPAD(TEST,(CEIL(DBMS_RANDOM.VALUE*10))*LENGTH(TEST),TEST)
bobbobbobbobbobbobbobbobbobbob
terryterry
stevestevesteve
rogerrogerrogerrogerrogerrogerrogerrogerrogerYou can alter the value of 10 in the SQL if you want the potential for a higher number of names.
Andy -
The sql
select 'alter system kill session '||sid||','||serial#||';' from v$session where username= 'EV05';
give the output in the below given form
alter system kill session 69,38769;
But i need the output to be
alter system kill session '69,38769';
Can some one re-writes the sql select statment,
Thanks
NaveenNaveen,
This isn't the forum for help with writing SQL - rather with using the SQL Developer product. In future, I would suggest that you use the SQL and PL/SQL forum for these sorts of questions.
However, to answer your question this time, you can include a ' in a string by having two together ie 'fred''s' will return the string fred's.
The following SQL will give you the result you want:
select 'alter system kill session '''||sid||','||serial#||''';' from v$session where username= 'EV05'; -
Need Help in correcting the sql statement
H Experts,
I am not if I can post this query in this section, but as I am executing this statement on repository DB , I assumed to post here.
I have a requirement to calculate the database sizes from the tables in repository.
table 1 : MGMT$DB_TABLESPACES_ALL : has the information on all the tablespace information from each database. and it has information of all the databases.
table 2: MGMT$DB_REDOLOGS_ALL : has the information on all the redolog files information from each database. and it has information of all the databases.
Now to calculate the size of each database , we need to collect the sizes from both tables and then need to add.
below is the sql i prepared and sql didn't return and systax error , but the final output is completely wrong. Seems like its multiplying the data somewhere and getting the wrong information.
please help me in doing the required modifications.
=================================================================================================
select a.TARGET_NAME "DATABASE_NAME" ,sum(a.TABLESPACE_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE ALLOCATED SPACE(GB)",
sum(a.TABLESPACE_USED_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE USED SPACE(GB)",
sum(a.TABLESPACE_SIZE/1024/1024/1024)-sum(a.TABLESPACE_USED_SIZE/1024/1024/1024) "DATABASE FREE SPACE(GB)"
from MGMT$DB_TABLESPACES_ALL a ,MGMT$DB_REDOLOGS_ALL b
where a.TARGET_NAME=b.TARGET_NAME and a.TARGET_Name like '%d2oem%'
group by a.target_name;
====================================================================================================
Note: There are multiple records having the same TARGET_NAME value in both the tables.
please Help me in correcting the sql statementH Experts,
I am not if I can post this query in this section, but as I am executing this statement on repository DB , I assumed to post here.
I have a requirement to calculate the database sizes from the tables in repository.
table 1 : MGMT$DB_TABLESPACES_ALL : has the information on all the tablespace information from each database. and it has information of all the databases.
table 2: MGMT$DB_REDOLOGS_ALL : has the information on all the redolog files information from each database. and it has information of all the databases.
Now to calculate the size of each database , we need to collect the sizes from both tables and then need to add.
below is the sql i prepared and sql didn't return and systax error , but the final output is completely wrong. Seems like its multiplying the data somewhere and getting the wrong information.
please help me in doing the required modifications.
=================================================================================================
select a.TARGET_NAME "DATABASE_NAME" ,sum(a.TABLESPACE_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE ALLOCATED SPACE(GB)",
sum(a.TABLESPACE_USED_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE USED SPACE(GB)",
sum(a.TABLESPACE_SIZE/1024/1024/1024)-sum(a.TABLESPACE_USED_SIZE/1024/1024/1024) "DATABASE FREE SPACE(GB)"
from MGMT$DB_TABLESPACES_ALL a ,MGMT$DB_REDOLOGS_ALL b
where a.TARGET_NAME=b.TARGET_NAME and a.TARGET_Name like '%d2oem%'
group by a.target_name;
====================================================================================================
Note: There are multiple records having the same TARGET_NAME value in both the tables.
please Help me in correcting the sql statement -
Need Help with Creating the SQl query
Hi,
SQL query gurus...
INFORMATION:
I have two table, CURRENT and PREVIOUS.(Table Defs below).
CURRENT:
Column1 - CURR_PARENT
Column2 - CURR_CHILD
Column3 - CURR_CHILD_ATTRIBUTE 1
Column4 - CURR_CHILD_ATTRIBUTE 2
Column5 - CURR_CHILD_ATTRIBUTE 3
PREVIOUS:
Column1 - PREV_PARENT
Column2 - PREV_CHILD
Column3 - PREV_CHILD_ATTRIBUTE 1
Column4 - PREV_CHILD_ATTRIBUTE 2
Column5 - PREV_CHILD_ATTRIBUTE 3
PROBLEM STATEMENT
Here the columns 3 to 5 are the attributes of the Child. Lets assume that I have two loads, One Today which goes to the CURRENT table and one yesterday which goes to the PREVIOUS table. Between these two loads there is a CHANGE in the value for Columns either 3/4/5 or all of them(doesnt matter if one or all).
I want to determine what properties for the child have changed with the help of a MOST efficient SQL query.(PARENT+CHILD is unique key). The Database is ofcourse ORACLE.
Please help.
Regards,
ParagHi,
The last message was not posted by the same user_name that started the thread.
Please don't do that: it's confusing.
Earlier replies give you the information you want, with one row of output (maximum) per row in current_tbl. There may be 1, 2 or 3 changes on a row.
You just have to unpivot that data to get one row for every change, like this:
WITH single_row AS
SELECT c.curr_parent
, c.curr_child
, c.curr_child_attribute1
, c.curr_child_attribute2
, c.curr_child_attribute3
, DECODE (c.curr_child_attribute1, p.prev_child_attribute1, 0, 1) AS diff1
, DECODE (c.curr_child_attribute2, p.prev_child_attribute2, 0, 2) AS diff2
, DECODE (c.curr_child_attribute3, p.prev_child_attribute3, 0, 3) AS diff3
FROM current_tbl c
JOIN previous_tbl p ON c.curr_parent = p.prev_parent
AND c.curr_child = p.prev_child
WHERE c.curr_child_attribute1 != p.prev_child_attribute1
OR c.curr_child_attribute2 != p.prev_child_attribute2
OR c.curr_child_attribute3 != p.prev_child_attribute3
, cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 3
SELECT s.curr_parent AS parent
, s.curr_child AS child
, CASE c.n
WHEN 1 THEN s.curr_child_attribute1
WHEN 2 THEN s.curr_child_attribute2
WHEN 3 THEN s.curr_child_attribute3
END AS attribute
, c.n AS attribute_value
FROM single_row s
JOIN cntr c ON c.n IN ( s.diff1
, s.diff2
, s.diff3
ORDER BY attribute_value
, parent
, child
; -
I need Help for Installing the JamVM on TS-7800 SCB
Hello,
can anyone give me some StarterHelp to install the JamVM (or any other VM) on the follwing SBC (Arm)?
http://www.embeddedarm.com/products/board-detail.php?product=TS-7800&tab=options
Didn't need I a crosscompiler for the target-arch? In the INSTALL-File of the jamvm-package i didn't reed somthing about using a crosscompiler.
For you help i'm very thanksfull.
Best regards.can u guys solve the problems??? i also working on the ARM board which came from China. my problem also almost the same.still configure how to run the java program on that board. i just read from this journal, http://www.linuxjournal.com/article/8757. this author said that we don't have to install JVM in our target. we just have to use GCJ (GNU Compiler for Java), which is will compiles our Java source down to the machine code for the target. but, the author used PowerPC target, that was the issue. i already try this method but it was not working yet. i also don't know why yet.please let me know if u guys can slove your problems. tq~
-
Need help for focusing the cursor from one textbox to another textbox
hii all,
I have a problem in java script.
Note:The textboxes are generated dynamically.it is not having fixed length.(the number of textboxes generated may be 3,2,4....etc.it is not fixed.
To move cursor from one textbox to another text box ,I have taken the length of the textboxes of the first column.I used onkeyDown event .
in the function ,first i checked the condition like
for(i=0;i<form1.box.length;i++) //box is the name of the textboxes
if(event.keyCode==13)
form1.box[i+1].focus();
return false;
by using this the cursor is moving from first text box to second textbox and stops.
if i use event.returnValue=false; instead of return false ,then the cursor automatically going to the laxt textbox of the column.
my problem is how i can focus the cursor from one textbox to another textbox one after the other till the end.
if any one has solution please help me.
also if we can do in another way also,please help me.
thanx.>thanx .u helped me so much.
i have to check another condition. see the code below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<SCRIPT language="Javascript">
function fnTest(str) {
if(event.keyCode==13) {
if(str == 4) {
formHeader.box[0].focus();
else {
formHeader.box[parseInt(str)+1].focus();
return false;
</SCRIPT>
<BODY>
<FORM name="formHeader">
<CENTER>
<INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('0');">
<br>
<INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('1');">
<br>
<INPUT TYPE="TEXT" name="box" value="0" disabled="false" onKeyDown="javascript:fnTest('2');">
<br>
<INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('3');">
<br>
<INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('4');">
</CENTER>
</FORM>
</BODY>
</HTML>
suppose if some of the fields are disabled,then the focus must skip to the next one.i have written disabled for box2.if the cursor focuses in box1,then the cursor should move to box3 escaping box2.
if u know plz tell me. -
Need help : for changing the flv movie size
i am loading my flv thogh xml link if load my flv the same
size what i kept in my folder using script shall i change the movie
size because lot of movies is loads dynmicaly i cannot go and
change each and evry movie
so some body can help me to change the movie - flv while it
loads.You should be able to change the product name in Google Cloud. The ChromeBook uses Google Cloud to print (Google Cloud uses HP ePrint). Log into your google account and change the printer name there.
I am an HP employee.
Opinions expressed are mine and do not necessarily reflect the opinions of HP.
Reminder: Please select the Accept as Solution button on the post that best answers your question. Also, you may select the Kudos button on any helpful post to give that person a quick thanks. -
Need help for importing oracle 10G dump into 9i database
hi, Someone help me to import oracle 10G dump into 9i database. I'm studying oracle . Im using oracle 10G developer suite(downloaded from oracle) and oracle 9i database. I saw some threads tat we can't import the higher version dumps into lower version database. But i'm badly need help for importing the dump...
or
someone please tell me the site to download oracle 9i Developer suite as i can't find it in oracle site...I didnt testet it to import a dump out of a 10g instance into a 9i instance if this export has been done using a 10g environment.
But it is possible to perform an export with a 9i environment against a 10g instance.
I am just testing this with a 9.2.0.8 environment against a 10.2.0.4.0 instance and is working so far.
The system raises an EXP-00008 / ORA-37002 error after exporting the data segments (exporting post-schema procedural objects and actions).
I am not sure if it is possible to perform an import to a 9i instance with this dump but maybe worth to give it a try.
It should potentially be possible to export at least 9i compatible objects/segments with this approach.
However, I have my doubts if this stunt is supported by oracle ...
Message was edited by:
user434854 -
Need help th tuning query or re write the query--
Hi,
Need help to tune the below query or rewrite th query for reducing the execution time Please find the query and explain plan.
QUERY
explain plan FOR SELECT consumer_key,product_key,days_in_product,20100201 period_key FROM
(SELECT consumer_key,
product_key,
days_in_product,
row_number() over ( Partition BY consumer_key order by Days_in_product DESC) row_num
FROM
(SELECT consumer_key,
product_key,
SUM(no_ofdays) days_in_product
FROM
(SELECT pcv.consumer_key,
pcv.product_key,
pcv.product_consumer_valid_from,
pcv.product_consumer_valid_to,
DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from) period_start,
DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959) period_end,
CASE
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date > to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN 0
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date BETWEEN to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') AND to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN
--to_char(activation_date,'MON-YYYY')='PERIOD_ACTIVE' and activation_date >= to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') then
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_date(TO_CHAR(activation_date,'YYYYMMDDHH24MISS'),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) < 20100201000000
THEN (to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) > 20100228235959
THEN 0
ELSE
--unusual situation
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
END No_ofDays
FROM cimtran.product_consumer_validity pcv,
consumer_dimension cd
WHERE pcv.consumer_key =cd.consumer_key
AND product_consumer_valid_to >= 20100201000000
AND product_consumer_valid_from <= 20100228235959
--and product_consumer_valid_from > '20090801000000'
ORDER BY consumer_key,
product_key,
product_consumer_valid_from
) a
GROUP BY consumer_key,
product_key
ORDER BY consumer_key,
product_key
) WHERE row_num=1 ;EXPLAIN PLAN
"PLAN_TABLE_OUTPUT"
"Plan hash value: 3823907703"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 1 | VIEW | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 2 | WINDOW SORT PUSHED RANK| | 4665K| 173M| 232M| 133K (1)| 00:31:08 |"
"| 3 | VIEW | | 4665K| 173M| | 104K (1)| 00:24:18 |"
"| 4 | SORT GROUP BY | | 4665K| 182M| 729M| 104K (1)| 00:24:18 |"
"|* 5 | HASH JOIN | | 13M| 533M| 65M| 44241 (1)| 00:10:20 |"
"| 6 | TABLE ACCESS FULL | CONSUMER_DIMENSION | 2657K| 35M| | 4337 (1)| 00:01:01 |"
"|* 7 | TABLE ACCESS FULL | PRODUCT_CONSUMER_VALIDITY | 13M| 351M| | 15340 (2)| 00:03:35 |"
"Predicate Information (identified by operation id):"
" 1 - filter(""ROW_NUM""=1)"
" 2 - filter(ROW_NUMBER() OVER ( PARTITION BY ""CONSUMER_KEY"" ORDER BY "
" INTERNAL_FUNCTION(""DAYS_IN_PRODUCT"") DESC )<=1)"
" 5 - access(""PCV"".""CONSUMER_KEY""=""CD"".""CONSUMER_KEY"")"
" 7 - filter(""PRODUCT_CONSUMER_VALID_FROM""<=20100228235959 AND "
" ""PRODUCT_CONSUMER_VALID_TO"">=20100201000000)"I doubt that this query can be tuned without using indexes. There is a lot of unnecessary work specified in your query, like unnecessary intermediate sorting and selecting unused columns. The cost based optimizer recognized it and skips some of that unnecessary work, it seems. For clarity's sake, I would rewrite your query like below. Note that the query is untested:
select consumer_key
, max(product_key) keep (dense_rank last order by days_in_product) product_key
, max(days_in_product) days_in_product
, 20100201 period_key
from ( select pcv.consumer_key
, pcv.product_key
, sum
( case
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) between 20100201000000 and 20100228235959
then
case
when cd.activation_date > to_date(pcv.product_consumer_valid_to,'yyyymmddhh24miss')
then
0
when cd.activation_date between to_date(pcv.product_consumer_valid_from,'yyyymmddhh24miss') and to_date(product_consumer_valid_to,'yyyymmddhh24miss')
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(activation_date,'yyyymmddhh24miss'),'yyyymmddhh24miss')
end
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) < 20100201000000
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(pcv.product_consumer_valid_from),'yyyymmddhh24miss'))
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) > 20100228235959
then
0
end
) days_in_product
from cimtran.product_consumer_validity pcv
, consumer_dimension cd
where pcv.consumer_key = cd.consumer_key
and product_consumer_valid_to >= 20100201000000
and product_consumer_valid_from <= 20100228235959
group by consumer_key
, product_key
group by consumer_keyRegards,
Rob. -
I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please
http://www.apple.com/support/itunes/contact/
-
Request for help in tuning the server which is running opmn process.
Hi Folks,
I request for an help in tuning the server which is running oracle app server opmn process , It is chewing arround 40% of the CPU resource,and our sysadmin is back of me to resolve this issues.
any feedback on this is highly appriciated...
Thanks in advanceRe: How to Achieve Performance Tuning
I hope you may find answers here..
Sharma -
Need help for the $200 promo rebate for trade-in of I Phone 4
Need help for the $200 promo rebate for trade-in of I Phone 4. Unable to preregister when I ordered the new 6 in September. Now can not contact VZW recycle program regarding.
When I ordered my phone on Sept. 13th in a Verizon store, I had to ask the salesman how I went about getting the $200 rebate. He said shipping materials would come with the new phones. When I received the confirmation e-mail of my order, it contained a link for the rebate. Fortunately I clicked on the link, filled out the form online, and received the packing materials to send my phone in shortly after. My phones came in on Oct. 14th and I sent 3 of them back. So far I have received a gift card for $200 for 2 of the phones; the other is showing not received. I don't know what your situation is, but I think the promotion ended Oct. 15th. If I had listened to the salesman I think I would be out of luck as well. I hope I am wrong for your sake.
-
I need heed help for Handle the JButton
hi, guys
I am writing a small program
It has name and number field.
It also has the first, privious, next , last and add buttons.
i want to load the myData.txt file to the name and number field.
and I want to make the buttons handle the events.
and when the application is closed, it will save the data into the files.
I can assign the the add button to save the files, and save the data when it is closed, but I can not make it save more than one record.
i need ur help to the rest of the buttons, and load the file back to the field.
andy suggestion would be great!
Thank !
here codes
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
import java.io.*;
public class buttonAction extends JFrame
private JLabel nameL;
private JLabel numberL;
private JTextField name;
private JTextField number;
private JButton first;
private JButton prev;
private JTextField current;
private JButton next;
private JButton last;
private JButton add;
private JButton exit;
private final int winw = 410;
private final int winh = 200;
private buttonAction()
super("Wage Calculate");
setSize(winw, winh);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new Closing());
setLayout (new BorderLayout());
loadData();
buildPanel();
buildButtomButtons();
setVisible(true);
private void buildPanel()
nameL = new JLabel("Name:");
numberL = new JLabel("Number:");
name = new JTextField(10);
number = new JTextField(5);
JPanel panel =new JPanel();
panel.setLayout(new GridLayout(2,1));
panel.add(nameL);
panel.add(name);
panel.add(numberL);
panel.add(number);
add(panel, BorderLayout.NORTH);
private void buildButtomButtons()
first = new JButton("First");
prev = new JButton("Prev");
current = new JTextField(5);
current.setEditable(false);
next = new JButton("Next");
last = new JButton("Last");
add = new JButton("Add");
exit = new JButton("Exit");
JPanel button = new JPanel();
first.addActionListener(new ButtonListener());
prev.addActionListener(new ButtonListener());
current.addActionListener(new ButtonListener());
next.addActionListener(new ButtonListener());
last.addActionListener(new ButtonListener());
add.addActionListener(new ButtonListener());
button.add(first);
button.add(prev);
button.add(current);
button.add(next);
button.add(last);
button.add(add);
add(button, BorderLayout.SOUTH);
// save the data into the file when the application is close
public class Closing extends WindowAdapter
public void windowClosing(WindowEvent e)
try {
PrintWriter out = new PrintWriter (new FileWriter("myData.txt"));
out.println (name.getText());
out.println(number.getText());
out.close();
catch (IOException ee) {
// Happens if the file cannot be written to for any reason
JOptionPane.showMessageDialog(null, "Could not save the file " + ee.getMessage());
System.exit(0);
private void loadData()
try {
BufferedReader fileReader = new BufferedReader(new FileReader(new File("myData.txt")));
String lineRead = fileReader.readLine();
// I need help how to load the data
catch (FileNotFoundException e)
e.printStackTrace();
catch (IOException e) {
e.printStackTrace();
//handle the first, previous, next, last, add buttons
private class ButtonListener implements ActionListener
public void actionPerformed(ActionEvent e)
Object button = e.getSource();
if (button == add)
try
PrintWriter out = new PrintWriter (new FileWriter("myData.txt"));
out.println (name.getText());
out.println(number.getText());
out.close();
catch (IOException ee)
// Happens if the file cannot be written to for any reason
JOptionPane.showMessageDialog(null, "Could not save the file " + ee.getMessage());
//I need help for the first, privious and last buttons
public static void main(String[] args)
buttonAction pr = new buttonAction();
}are you trying to load a multi line textfile int a JTextField? If you try to load this in a while loop as you read the file, it will zoom through the file, and you will probably only see the last line of the file (or nothing if the last line is blank) in the jtextfield. Consider using a JTextArea or some other component that can hold multiple lines. Also your file reading method calls look wrong to me. You appear to read a line, then continually check if that one read line is null, and if not do a while loop, that looks to loop forever. Look at the java I/O examples for how to do this right.
Good luck -
I Need Help for the popup message every time I go to safari: "Warning! Old version of Adobe Flash Player detected. Please download new version."???
If you are talking about Safari on the iPad, there is no version of Adobe Flash for iOS and there never has been. Clear Safari, close the app and reset the iPad.
Go to Settings>Safari>Clear History and Website Data
In order to close apps, you have to drag the app up from the multitasking display. Double tap the home button and you will see apps lined up going left to right across the screen. Swipe to get to the app that you want to close and then swipe "up" on the app preview thumbnail to close it.
Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
If you are talking about Safari on your Mac, you are in the wrong forum. But I would still clear the cache, quit Safari and restart the Mac.
Maybe you are looking for
-
Product warning messages not shown in WCEM
Hi, I am facing a problem regarding product warning messages in WCEM 3.0. If a product is having status I1050 (Blocked - Error), message CRM_PRODUCT_I message 420 is shown in WCEM and it is not orderable. (Correct behaviour) If a product is having st
-
Hi Guru's I am trying to print an invoice which has a line item in negative balance also, but when invoice is printed, it only prints items with positive balance, however the total on the bottom is a net off figure which is correct. Why it is not pri
-
POC day wise caluation and report
Dear Is any report that will be showing the day wise Plan POC and Actual POC progress.I am using the TIME PROP measurement method. please also correct me if measurement method is wrong. thanks
-
Startup resolution issues on Retina Display
I am not sure what I did; however, now when my machine boots the initial logon screen is at a very weird resolution. Also do not know why this photo is up-side-down here as it is was taken on an iPhone 6+. Someone isn't handling the XIFF information
-
Protecting user accounts - Reducing user account sharing
Dear friends, Our Internal Audit Dept believes that some employees may be sharing SAP users (and password) to avoid the SoD in place. With password-based authentication, that we must use, there is no chance that the system can prevent it. However, to