This is a procedure which has one out parameter of SYS_REFCURSOR type.
PROCEDURE p_get_data(query_result OUT SYS_REFCURSOR);
In java for working out with this procedure you need to import ojdbc14.jar and need to set registerOutParameter type as OracleTypes.CURSOR
import oracle.jdbc.driver.OracleTypes;
CallableStatement callStmt = connection.prepareCall("{call p_get_data(?)}");
callStmt.registerOutParameter(1, OracleTypes.CURSOR);
callStmt.execute();
ResultSet resultSet = (ResultSet) callStmt.getObject(1);
if(resultSet.next()) {
//Your Code here
}
SQL Developer date and time column returns only date so if you want to see both date and time on SQL developer then you have to make just a small change in SQL Developer's Preferences.
Go to Tools >> Preferences
Preferences >> Database >> NLS
set the Date Format as DD-MON-RR HH24:MI:SS
java.util.Date : The class Date represents a specific instant in time, with millisecond precision.
Code :
java.util.Date dtUtil = new java.util.Date();
System.out.println(dtUtil);
Output :
Mon Mar 28 21:35:05 IST 2016
java.sql.Date : A thin wrapper around a millisecond value that allows JDBC to identify this as an SQL DATE value. A milliseconds value represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT.
To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.
long java.util.Date.getTime() :
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by Date object.
Code : Convert java.util.Date to java.sql.Date
java.sql.Date dtSql = new java.sql.Date(dtUtil.getTime());
System.out.println(dtSql);
Output :
2016-03-28
java.sql.Timestamp : A thin wrapper around java.util.Date that allows the JDBC API to identify this as an SQL TIMESTAMP value. It adds the ability to hold the SQL TIMESTAMP fractional seconds value, by allowing the specification of fractional seconds to a precision of nanoseconds.
Code :
java.sql.Timestamp dtTime = new java.sql.Timestamp(dtUtil.getTime());
System.out.println(dtTime);
Output :
2016-03-28 21:35:05.181
java.text.SimpleDateFormat : SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date ? text), parsing (text ? date), and normalization.
Code :
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String dt = sdf.format(dtTime);
System.out.println(dt);
Output :
28-03-2016 21:35:05
Many-times I have to charge my mobile with my laptop but i can not down my laptop's lid because of phone charging goes off. But Now i can charge my mobile even by closing my laptop lid with a small change in Device Manager Setting.
Important : This will only work when your laptop is charging (Not using Laptop Battery)
Device Manager >> Universal Serial Bus Controllers >> Generic USB Hub >> Properties
Power Management :
Uncheck "Allow this computer to turn off this device to save power"
If This solution is not working then go to your Laptop BIOS to Enable "USB Wake Support".
BIOS >> Advanced >> USB Wake Support
Enable USB Wake Support and then exit with save.
Also Read : Windows 8 : Add or Remove Sleep or Hibernate in Power Options Menu of your PC
Also Read : Stop or disable skype Auto-launching in Windows 8 on startup
 |
| Employee Table |
SELECT SALARY FROM EMPLOYEE ORDER BY SALARY DESC;
OUTPUT :
SALARY
----------
77777
60000
34000
23232
Example to find the 2rd highest salary
SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMPLOYEE);
OUTPUT :
MAX(SALARY)
-----------
60000
Example to find the 3rd highest salary
After union query is omitting first highest salary.
SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMPLOYEE) UNION SELECT MAX(SALARY) FROM EMPLOYEE);
OUTPUT :
MAX(SALARY)
-----------
34000
Also Read : Oracle and MySql : Find Top 3rd highest salary row from employee table
Disclaimer
We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.