Static import means that the fields and methods in a class can be used in the code without specifying their class if they are defined as public static.The Math class methods sqrt() and pow() in the package java.lang are static imported. A program that demonstrates this is given as follows:Example Live Demoimport static java.lang.Math.sqrt; import static java.lang.Math.pow; public class Demo { public static void main(String args[]) { double num = 4.0; System.out.println("The number is: " + num); System.out.println("The square root of the above number is: " + sqrt(num)); ... Read More
The connection_status() function returns the connection status.Syntaxconnection_status()ParametersNAReturnThe connection_status() function returns the following possible values. This is the status bitfield −0 - CONNECTION_NORMAL - connection is running normally1 - CONNECTION_ABORTED - connection is aborted by user or network error2 - CONNECTION_TIMEOUT - connection timed out3 - CONNECTION_ABORTED & CONNECTION_TIMEOUTExampleThe following is an example − Live Demo
The following is an example to implement MySQL WHILE LOOP with IF statement. We are using in a stored procedureThe following is the query to create our stored procedure:mysql> DELIMITER // mysql> create procedure sp_getDaysDemo() -> BEGIN -> SELECT MONTH(CURDATE()) INTO @current_month; -> SELECT MONTHNAME(CURDATE()) INTO @current_monthname; -> SELECT DAY(LAST_DAY(CURDATE())) INTO @total_numberofdays; -> SELECT CAST(DATE_FORMAT(NOW() ,'%Y-%m-01') as DATE)INTO @check_weekday; -> SELECT DAY(@check_weekday) INTO @check_day; -> SET @count_days = 0; -> SET @workdays = 0; ... Read More
The truncate BigDecimal value in Java, try the following code.Here, we have taken two BigDecimla values and set the round mode for truncating the decimal values −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { int decPlaces1 = 3; int decPlaces2 = 5; BigDecimal val1 = new BigDecimal("37578975587.876876989"); BigDecimal val2 = new BigDecimal("62567875598.976876569"); System.out.println("Value 1 : "+val1); ... Read More
To extract last word from a field, use in-built SUBSTRING_INDEX() function. The syntax is as follows −SELECT SUBSTRING_INDEX(yourColumnName, ’ ‘, -1) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table FirstWordDemo −> ( −> AllWords longtext −> ); Query OK, 0 rows affected (0.83 sec)Now insert some words in the table using insert command. The query is as follows −mysql> insert into FirstWordDemo values('This is the first MySQL Query'); Query OK, 1 row affected (0.11 ... Read More
To select last 20 records in ascending order, you can use subquery LIMIT clause. The syntax is as followsSELECT *FROM ( SELECT *FROM yourTableName ORDER BY yourColumnName desc limit 20 ) anyVariableName order by anyVariableName.yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table ProductInformation -> ( -> ProductId int, -> ProductName varchar(100), -> ProductPrice int -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command. The query is as followsmysql> insert into ProductInformation values(101, 'Product-1', ... Read More
Bitcode – Bitcode is an intermediate reperesentation of how the code looks. This code can not be used by us or can’t be installed on a device. When we upload our application to the app store It is uploaded as an bitcode and later converted to app binary by itunes/Apple.When the Intermediate code is created an uploaded to the App store or run on the device, a program called LLMV takes over the control and converts the Intermediate code to a Binary file which is x86 32Bit or x86 64 bit for the simulator and ARM for the actual iOS handheld ... Read More
A string representation of an object can be obtained using the toString() method in Java. This method is overridden so that the object values can be returned.A program that demonstrates this is given as follows:Example Live Democlass Student { private int rno; private String name; public Student(int r, String n) { rno = r; name = n; } public String toString() { return rno + " " + name; } } public class Demo { public static void main(String[] args) { Student ... Read More
Information technology – often shortened to just IT – is a buzz phrase you would probably hear when you talk about anything related to computers. IT nerds are often highly specialized in their particular field and are a part of every single company, small or big. They are the essential employees of each and every modern business model. Hence we can say there is no dearth of options for an IT guy.Here are some of the courses which carve your IT Career in India:A bachelor's degree in computer science is the basic education required for almost all IT jobs.Cloud Architecture ... Read More
To find all upper case strings in a MySQL table, you need to use BINARY UPPER() function. The syntax is as follows:SELECT *FROM yourTableName WHERE yourColumnName=BINARY UPPER(yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table FindUpperCaseDemo -> ( -> Id int, -> FirstName varchar(20), -> Age int -> ); Query OK, 0 rows affected (1.04 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into FindUpperCaseDemo values(1, 'John', 23); Query OK, 1 row affected (0.17 sec) mysql> ... Read More