Java program to calculate next execution time if one cron expression is giv
In my project requirement i wanted to have one function which will calculate next execution time using cron expression.
Here i have one cron expression which says every 25 minutes, i want to have one function which will be passed with cron expression and time and function should return next execution time.
I was wondering if any ready function available for the same.
Thanks in Advance
[Did you check here?|http://www.lmgtfy.com/?q=java+cron+expression]
Similar Messages
-
Hi!,
I wanto to calculate what time Java need to do the execution of some methods...You can use the system clock,
long time = System.currentTimeMillis();
// do something
System.out.println("Time= " + (System.currentTimeMillis()-time));The problem is the system clock has a resolution of about 1 millisecond. So you probably will have to call your methods many times and then calculate the average. -
Running a java program a set number of times
This is a general question. Is it possible to make a java program run only 5 times for the sake of arguement.
Basically I want to write a program that will give the user some flexibility when it will actually run another Java program, but I only want them to be able to say "not now' for a set number of times. When the last time comes the other program will launch. I was initially thinking of the Do Whilw loop, but this needs to work when the program is restarted.
Program starts, it has 5 times it will run before it does something else(doesn't really matter now I think). User takes option "Not Now" and the program ends, but warns the user this will run 4 more times before you will need to do something.
This process will repeat until the user takes the option "Ok install now" or the time limit expires and the install occurs anyway. Can someone point me in the right direction.ok I see so it's like one those programs that you download for free on the internet and they give you a set amount times to use it before you have to pay for it. but in this case when the number of times you use it equals 5 (or when the user clicks ok) a different java app will open automatically.
My first thought would be to Write a Serialized object to disk using objectOutputStream that stores the number of times the application has been opened. and each time the program runs it checks for the serialized object and then you can do something like what I posted before. of course if were worried about security the user could always look for the object and erase it, if so then I guess we would have to come up with another plan of attack
Hope this helps -
Running a Java program automatically at a specified time
How to run a Java appln automatically at a specified time?
Java Application, or method within a running Java application?
To run Java you would have to use the OS native tools.
Windows Scheduled Tasks
Newbie: Intro to cron.
To execute a block of code within a running Java VM, you want to look at Timer. -
How to find the Execution Time for Java Code?
* Hi everyone , i want to calculate the execution time for my process in java
* The following was the ouput for my coding,
O/P:-
This run took 0 Hours ;1.31 Minutes ;78.36 Seconds
*** In the above output , the output should come exactly what hours , minutes and seconds for my process,
but in my code the minutes are converted into seconds(It should not)...
* Here is my coding,
static long start_time;
public static void startTime()
start_time = System.currentTimeMillis();
public static void endTime()
DecimalFormat df = new DecimalFormat("##.##");
long end_time = System.currentTimeMillis();
float t = end_time - start_time;
float sec = t / 1000;
float min = 0, hr = 0;
if (sec > 60) {
min = sec / 60;
if (min > 60) {
hr = min / 60;
System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
}* How to Calcualte exact timing for my process....
* Thanks* Hi flounder, Is following code will wotk perfectly?
public static void endTime()
DecimalFormat df = new DecimalFormat("##.##");
long end_time = System.currentTimeMillis();
float t = end_time - start_time;
float sec = t / 1000;
float min = 0, hr = 0;
while(sec >= 60){
min++;
sec = sec -60;
if (min >= 60){
min = 0; //or min = min -60;
hr++;
System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
} -
How to calculate Execution Time
Hi gurus,
Can any one tell me how to calculate the Report Execution time in Seconds.
We have one requirement.My manager told me track all the reports in Development server how much time those take to execute. and Compare those with Production server.
I dont have an Idea how to calculate the Execution time in Seconds.
Please guide me on this.
Thanks in Advance
Thanks and Regards
Siri...hi
check se30
enter the prog name and press execute.
after your execution is over press back
then press evaluate in the initial screen.
you have the analysis
in that you will get the time in microseconds and you can convert to sec
REWARD IF HELPFUL
PRASANTH -
How to find out the execution time of a sql inside a function
Hi All,
I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
RETURN NUMBER
IS
exec_time NUMBER;
BEGIN
--Calculate the execution time for the incoming sql statement.
RETURN exec_time;
END function_name;
/Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
A simple test case shows the potential difference of work performed by the database:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Session altered.
SQL>
SQL> drop table count_test purge;
Table dropped.
Elapsed: 00:00:00.17
SQL>
SQL> create table count_test as select * from all_objects;
Table created.
Elapsed: 00:00:02.56
SQL>
SQL> alter table count_test add constraint pk_count_test primary key (object_id)
Table altered.
Elapsed: 00:00:00.04
SQL>
SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.29
SQL>
SQL> set autotrace traceonly
SQL>
SQL> select * from count_test;
5326 rows selected.
Elapsed: 00:00:00.10
Execution Plan
Plan hash value: 3690877688
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5326 | 431K| 23 (5)| 00:00:01 |
| 1 | TABLE ACCESS FULL| COUNT_TEST | 5326 | 431K| 23 (5)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
419 consistent gets
0 physical reads
0 redo size
242637 bytes sent via SQL*Net to client
4285 bytes received via SQL*Net from client
357 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5326 rows processed
SQL>
SQL> select count(*) from (select * from count_test);
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 572193338
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| PK_COUNT_TEST | 5326 | 5 (0)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
16 consistent gets
0 physical reads
0 redo size
412 bytes sent via SQL*Net to client
380 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle:
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Cannot call ANY stored functions from my Java program
My problem is that I cannot call ANY stored procedure from my Java
program. Here is the code for one of my stored procedures which runs
very well in PL/SQL:
PL/SQL code:
CREATE OR REPLACE PACKAGE types AS
TYPE cursorType IS REF CURSOR;
END;
CREATE OR REPLACE FUNCTION list_recs (id IN NUMBER)
RETURN types.cursorType IS tracks_cursor types.cursorType;
BEGIN
OPEN tracks_cursor FOR
SELECT * FROM accounts1
WHERE id = row_number;
RETURN tracks_cursor;
END;
variable c refcursor
exec :c := list_recs(11)
SQL> print c
COLUMN1 A1 ROW_NUMBER
rec_11 jacob 11
rec_12 jacob 11
rec_13 jacob 11
rec_14 jacob 11
rec_15 jacob 11
Here is my Java code:
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class list_recs
public static void main(String args[]) throws SQLException,
IOException
String query;
CallableStatement cstmt = null;
ResultSet cursor;
// input parameters for the stored function
String user_name = "jacob";
// user name and password
String user = "jnikom";
String pass = "jnikom";
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
try { Class.forName ("oracle.jdbc.driver.OracleDriver"); }
catch (ClassNotFoundException e)
{ System.out.println("Could not load driver"); }
Connection conn =
DriverManager.getConnection (
"jdbc:oracle:thin:@10.52.0.25:1521:bosdev",user,pass);
try
String sql = "{ ? = call list_recs(?) }";
cstmt = conn.prepareCall(sql);
// Use OracleTypes.CURSOR as the OUT parameter type
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
String id = "11";
cstmt.setInt(2, Integer.parseInt(id));
// Execute the function and get the return object from the call
cstmt.executeQuery();
ResultSet rset = (ResultSet) cstmt.getObject(1);
while (rset.next())
System.out.print(rset.getString(1) + " ");
System.out.print(rset.getString(2) + " ");
System.out.println(rset.getString(3) + " ");
catch (SQLException e)
System.out.println("Could not call stored function");
e.printStackTrace();
return;
finally
cstmt.close();
conn.close();
System.out.println("Stored function was called");
Here is how I run it, using Win2K and Oracle9 on Solaris:
C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>java
list_recs
Could not call stored function
java.sql.SQLException: ORA-00600: internal error code, arguments:
[ttcgcshnd-1], [0], [], [], [], [], [], []
at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at
oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:490)
at
oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2661)
at
oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4189)
at
oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4123)
at
oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:541)
at list_recs.main(list_recs.java:42)
C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>
Any help is greatly appreciated,
Jacob NikomThank you for your suggestion.
I tried it, but got the same result. I think the difference in the syntax is due to the Oracle versus SQL92 standard
conformance. Your statament is the Oracle version and mine is the SQL92. I think both statements are acceptable
by the Oracle.
Regards,
Jacob Nikom -
Execution time of a flat-sequence
Hello there -
Is there any way to get a measurement of how long each part of
the flat sequence takes to execute? Anything like matlab's "tic" and "toc"
commands in labview? I have been playing with it for a while now and
have yet to discover if Labview has this functionality. Anyone know of
anything like this?
I currently have a VI that controls the realtime acquisition of a CCD camera via Firewire and a USB spectrometer. The VI collects data from each of these devices (triggered by an external source at 10Hz), and dumps them into a Matlab script which does analysis on the CCD image and spectrum. The bulk of the VI sits inside a while loop, which continues to run until the user presses the stop button. Inside this main loop is a flat-sequence. The sequence goes: ACQUIRE DATA ---> PROCESSING DATA ----> MATLAB SCRIPT ----> PLOTTING GRAPHS -----> OUTPUT DATA TO FILE.
The problem here is that the VI runs at 5Hz, while we are triggering it at 10Hz. Originally, it was my thought thought that the matlab algorithm was to blame, but I used the matlab commands "tic" and "toc" to determine that the matlab algorithm runs in 15-20ms. I did this by putting a "tic" command at the top of the matlab algorithm and a "toc" command at the bottom. The problem, as I have now discovered is that the rest of the labview code takes ~180ms to execute. (This was discovered by putting the "tic" at the bottom of the program, and the "toc" at the top of the program, thereby measuring the execution time of everything except the matlab algorithm). Each time a trigger signal from the external source comes in, it starts the flat-sequence structure (which takes ~190ms), and then waits for another trigger signal, always missing every second signal. My eventual goal is to reduce the bloat, and get the algorithm down to less than 100ms, so that I can run the VI and acquire data at 10Hz rather than 5Hz. If anyone can offer some help with this, it would be much appreciated!
Eric
P.S. - I have attached a copy of the VI that I am working on, but unfortunately, it most likely will not run on your computer....the VI will not run unless it is connected to a triggered spectrometer and CCD camera....but I have attached it anyways incase anyone who can help might want to take a look.
Attachments:
RTSpider.vi 376 KBcan we divide the program into 2 parts and use background process for acquisition and front end process for analysis?
I mean, create 2 VIs from the present VI and then launch the acquisition program dynamically as a background process and fire events in Main VI from acquisition VI and process it. not sure how much it is going to reduce. lets give a try....
Anil Punnam
CLD
LV 2012, TestStand 4.2.......... -
Oracle View that stores the Query execution time
Hi Gurus
i m using Oracle 10G in Unix. I wudiold like to know which Data dictionary view stores the execution of a query. If it is not stored then hw to find the query execution time other than (Set timing on) command. What is the use of elapsed time and what is the difference between execution time and elapsed time? How to calculate the execution time of a query.
THanks
RamIf you have a specific query you're going to run in SQL*Plus, just do
a 'set timing on' before you execute the query.
If you've got application SQL coming in from all over the place, you can
identify specific SQL in V$SQL/ and look at ELAPSED_TIME/EXECUTIONS
to get an average elapsed time.
If you've got an application running SQL, and you need to know the
specific timing of a specific execution (as opposed to an average),
you can use DBMS_SUPPORT to set trace in the session that your
application is running in, and then use TkProf to process the resulting
trace file. -
Hi,
I have a query which fetches around 100 records from a table which has approximately 30 million records. Unfortunately, I have to use the same table and can't go ahead with a new table.
The query executes within a second from RapidSQL. The problem I'm facing is it takes more than 10 minutes when I run it through the Java application. It doesn't throw any exceptions, it executes properly.
The query:
SELECT aaa, bbb, SUM(ccc), SUM(ddd), etc
FROM MyTable
WHERE SomeDate= date_entered_by_user AND SomeString IN ("aaa","bbb")
GROUP BY aaa,bbbI have an existing clustered index on SomeDate and SomeString fields.
To check I replaced the where clause with
WHERE SomeDate= date_entered_by_user AND SomeString = "aaa"No improvements.
What could be the problem?
Thank you,
LoboIt's hard for me to see how a stored proc will address this problem. I don't think it changes anything. Can you explain? The problem is slow query execution time. One way to speed up the execution time inside the RDBMS is to streamline the internal operations inside the interpreter.
When the engine receives a command to execute a SQL statement, it does a few things before actually executing the statement. These things take time. First, it checks to make sure there are no syntax errors in the SQL statement. Second, it checks to make sure all of the tables, columns and relationships "are in order." Third, it formulates an execution plan. This last step takes the most time out of the three. But, they all take time. The speed of these processes may vary from product to product.
When you create a stored procedure in a RDBMS, the processes above occur when you create the procedure. Most importantly, once an execution plan is created it is stored and reused whenever the stored procedure is ran. So, whenever an application calls the stored procedure, the execution plan has already been created. The engine does not have to anaylze the SELECT|INSERT|UPDATE|DELETE statements and create the plan (over and over again).
The stored execution plan will enable the engine to execute the query faster.
/> -
PHP. How is execution time calculated?
As, unfortunately, I am rather good at programming infinite
loops, I have set
the maximum execution time on the test version of my program
to one second.
However it usually seems to take anything up to about a
minute to time out,
after which it announces that the maximum execution time of
one second has been
exceeded.
Why is there such a large discrepancy?
Clancy.oO(Clancy)
>As, unfortunately, I am rather good at programming
infinite loops, I have set
>the maximum execution time on the test version of my
program to one second.
>However it usually seems to take anything up to about a
minute to time out,
>after which it announces that the maximum execution time
of one second has been
>exceeded.
>
>Why is there such a large discrepancy?
The set_time_limit directive doesn't set the "real" clock
time after
which the script will be killed. It's a bit more complicated
and there
are some more things to consider.
It depends on what the script is actually doing, because many
kinds of
operations like IO stuff, database operations, system calls
etc. do not
count to the execution time. If the script is just sleeping
and idling
around, it won't eat up any CPU time, so it might run a lot
longer than
just the time defined with set_time_limit.
In other cases the web server can be an issue as well,
especially when
you use a script to send large files to the browser. The
download might
take much more time than the PHP script is allowed to run,
because the
script delivers its content to the web server, which will
cache it on
its own before its delivered to the browser. And then the
script can be
finished already, while the download is still running.
So there are many things that have to be taken into account
when it
comes to determine the real script execution time.
Micha -
For loop 1 iteration execution time
Hi,
what is the time taken of for loop 1 iteration without code inside.How to calculate this Execution time.Ravindranath.K wrote:
Hi,
what is the time taken of for loop 1 iteration without code inside.How to calculate this Execution time.
No code in the FOR loop? It will not use any time because the compiler will optimize it out.
Why do you even need to know?
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Hi experts,
I am developing an editor which is not only capable of writing java programs but at the same time it should be able to execute them using a menu option.Keeping this in view i started my work,i achieved it up to 80%,but overall i regard it not up to the mark.
The reason is compilation keeps me waiting for 10 sec with some redundant time in between,i am using java runtime environment
Runtime.getRuntime.execute()
Further i am able to execute only swing applications,
System.out.println() works at few occasion but not all.If i use getOutputStream()(),getInputStream(),getErrorStream methods ,even then limited functionality is achieved.
I changed the logic by switching on to creating a batch file and then executing it using Runtime.getRuntime.execute().Batch file contains
java <progname>
It stucks up too !!I would suggest you look at eclipse, and netbeans which does what you suggest and much, much more.
You can get the source for these and see what they do. This might help you, or you could just use one of these iDEs. -
How to read card reader (bar code reader) in simple java program ?
hai all
how to manipulate (read/write) card readers (or bar code reader ) in
a java program ?
should i import any particular package library ?
pls give me any sample code or tutorials or tools, etc (whatever you have) .
i am new to this card reader category
its very urgent
thank you .Nearly all card readers and barcode readers I've ever seen simply stick their input right onto stdin, so you can capture it just as if it had been typed in on a keyboard
Maybe you are looking for
-
HTTPS 2-way authentication doesn't work.
I succeeded in setting up my server (WL 6.1) to use SSL and enforce client authentication. I created a client certificate with OpenSSL, and imported it into my browser. When I request the page https://localhost:7002/ I get following message in the lo
-
Setting Multi Variables with Multi SQL Queries: Performance Bottleneck?
Hello ODI Experts, I have created a Logical & Physical Schema and Source Data Store to pick data from DB Table. Now I am setting variables with simple SELECT Query for setting each variable (in its Refreshing tab>Select Query field). It gives me a le
-
Cancel of reuqest does not lead to cancel, in presentation service
Hi Team, Kindly let me know how to find a sql session that is running for a long time and to kill it from back end by a dba.(obiee 11g) One of the user running a request,when he tried to cancel it ,taking very long time.the status is in cancelling on
-
How to create a name space.
answer me plz. thank you for your concerning.
-
When downloading from iTunes I received this message: unkown error 12001
when downloading from iTunes I received this message: unkown error 12001. Anyone knows what this is and how to fix it?