Create Instant from Epoch Second and Millisecond in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

1K+ Views

Create Instant from Epoch SecondExampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant instant = Instant.ofEpochSecond(282829279);       System.out.println(instant);    } }Output1978-12-18T11:41:19ZCreate Instant from Epoch MillisecondsExampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant instant = Instant.ofEpochMilli(272827282728l);       System.out.println(instant);    } }Output1978-08-24T17:21:22.728Z

Remove Every Column in a Table in MySQL

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

135 Views

In order to remove every column in a table in MySQL, you can use DROP TABLE command. Following is the syntax:DROP TABLE yourTableName;Let us first create a table:mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName varchar(20),    StudentAge int,    StudentAddress varchar(200),    StudentCountryName varchar(30),    StudentDateOfBirth datetime ); Query OK, 0 rows affected (0.85 sec)Let us check the description of table using DESC command:mysql> desc DemoTable;This will produce the following output:+--------------------+--------------+------+-----+---------+----------------+ | Field              | Type         | Null | Key ... Read More

intBuffer hasArray Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

124 Views

It can be checked if a buffer has the backing of an accessible int array by using the method hasArray() in the class java.nio.IntBuffer. This method returns true if the buffer has the backing of an accessible int array and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          IntBuffer buffer = IntBuffer.allocate(5);          buffer.put(8);          buffer.put(1);         ... Read More

8086 Program to Convert ASCII to BCD Number

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

4K+ Views

In this program we will see how to find the equivalent BCD number from an ASCII value.Problem StatementWrite 8086 Assembly language program to find the equivalent BCD number from an ASCII value. The number is stored at memory location 2050 and store the result at memory location 3050.DiscussionThis program can change ASCII value of a number to its BCD (Decimal) form. The ASCII values of the numbers are like below:ASCII (in Hex)30313233343536373839BCD00010203040506070809 From this table we can easily find that the last nibble of the ASCII value is actually the BCD equivalent. So to take the last nibble we have masked ... Read More

Select Query Using MySQL and Avoid Sorting in It

Samual Sam
Updated on 30-Jul-2019 22:30:25

298 Views

Using IN() sorts the result for the specific field. To avoid this, use ORDER BY and FIND_IN_SET() for the field.To understand the find_in_set(), let us create a table. The query to create a table is as follows −mysql> create table ProductStock    -> (    -> ProductId int,    -> ProductName varchar(20),    -> ProductQuantity int,    -> ProductPrice float    -> ); Query OK, 0 rows affected (0.79 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into ProductStock values(1, 'Product-101', 10, 500.56); Query OK, 1 row affected (0.20 ... Read More

IsThreadSafe Attribute in JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

2K+ Views

The isThreadSafe option marks a page as being thread-safe. By default, all JSPs are considered thread-safe. If you set the isThreadSafe option to false, the JSP engine makes sure that only one thread at a time is executing your JSP.The following page directive sets the isThreadSafe option to false −

Process SQL Statements with JDBC: Explained with Example

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

6K+ Views

To process an SQL statement, you need to follow the steps given below:Establish the connection.Create a statement.Execute the statement/query.Process the result.Close the connection.Establishing a ConnectionTo process SQL statements first of all you need to establish connection with the desired DBMS or, file System or, other data sources.To do so, Register the JDBC driver class, corresponding to the DataSource you need to the DriverManager using the registerDriver() method.Driver myDriver = new com.mysql.jdbc.Driver(); DriverManager.registerDriver(myDriver);This method accepts an object of the Driver class; it registers the specified Driver with the DriverManager.You can also register the driver using the forName() method. This method loads ... Read More

IntStream findFirst Method in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:25

405 Views

The findFirst() method in Java returns an OptionalInt describing the first element of this stream. If the stream is empty, an empty OptionalInt is returned.The syntax is as followsOptionalInt findFirst()Here, OptionalInt is a container object which may or may not contain an int value.To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;For OptionalInt class, import the following packageimport java.util.OptionalInt;First, create an IntStream and add elementsIntStream intStream = IntStream.of(30, 45, 70, 80, 90, 120);Now, get the first element of this streamOptionalInt res = intStream.findFirst();The following is an example to implement IntStream findFirst() method in JavaExample Live Demoimport java.util.OptionalInt; ... Read More

IntStream concat Method in Java

Anvi Jain
Updated on 30-Jul-2019 22:30:25

293 Views

The concat() method in the Java IntStream class forms a concatenated stream. The elements of this stream are all the elements of the first stream followed by all the elements of the second stream.The syntax is as follows −static IntStream concat(IntStream one, IntStream two)Here, the parameter one is the first stream, whereas two is the second stream. The method returns the concatenated result of the stream one and two.Let us create two IntStream and add some elements −IntStream intStream1 = IntStream.of(10, 20, 30, 40, 50); IntStream intStream2 = IntStream.of(60, 70, 80, 90);Now, to concate both the streams, use the concat() ... Read More

Add WHERE Clause in MySQL INSERT Statement

Chandu yadav
Updated on 30-Jul-2019 22:30:25

254 Views

You need to use UPDATE statement for this.The syntax is as followsupdate yourTableName set yourColumnName1=yourValue1, yourColumnName2=yourValue2, ....N where yourCondition;Let us create a table for our examplemysql> create table addWhereClauseDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(30),    -> StudentPassword varchar(40)    -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into addWhereClauseDemo(StudentName, StudentPassword) values('John', 'John123456'); Query OK, 1 row affected (0.14 sec) mysql> insert into addWhereClauseDemo(StudentName, StudentPassword) values('Carol', '99999'); Query OK, 1 row affected (0.24 sec) mysql> insert ... Read More

Advertisements