A view of the ByteBuffer can be created as a DoubleBuffer using the asDoubleBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns a double buffer as required. This buffer reflects the changes made to the original buffer and vice versa.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 = 50; try { ByteBuffer bufferB = ByteBuffer.allocate(n); DoubleBuffer bufferD = bufferB.asDoubleBuffer(); ... Read More
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to filter data using where Clause and “IN” in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill ... Read More
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use INTERSECT operator in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More
The JSP expression language defines the following literals −Boolean − true and falseInteger − as in JavaFloating point − as in JavaString − with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \.Null − null
The ResultSet interface provides the method named getClob() to retrieve clob datatype from a table in a database. In addition to this it also provides a method named getCharacterStream()Like getClob() this method also accepts an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the specified column. The difference is unlike the getClob() method (which returns a Clob object) this method returns an object of the Reader class.ExampleAssume we have created a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field | Type ... Read More
The forEachOrdered() method in Java assures that each element is processed in order for streams that have a defined encounter order.The syntax is as followsvoid forEachOrdered(IntConsumer action)Here, the action parameter is a non-interfering action to be performed on the elements.Create an IntStream and add elements to the streamIntStream intStream = IntStream.of(50, 70, 80, 100, 130, 150, 200);Now, use the forEachOrdered() method to display the stream elements in orderintStream.forEachOrdered(System.out::println);The following is an example to implement IntStream forEachOrdered() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { ... Read More
Create Decade Tuple in Java using a constructor or with() method. Here, we will see how to create a Decade of Tuple using constructor.Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following package −import org.javatuples.Decade;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How ... Read More
You can use the aggregate framework to find duplicate records in MongoDB. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"John"}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a330293b406bd3df60e01") } > db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"John"}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a330493b406bd3df60e02") } > db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"Carol"}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a330c93b406bd3df60e03") } > db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"Sam"}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a331093b406bd3df60e04") } > db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"Carol"}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a331593b406bd3df60e05") } > db.findDuplicateRecordsDemo.insertOne({"StudentFirstName":"Mike"}); { ... Read More
To achieve this, you need to set sql_log_bin to 0. To understand the concept, let us create a table. The query to create a table is as followsmysql> create table SQLStatementsDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20) -> ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into SQLStatementsDemo(UserName) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into SQLStatementsDemo(UserName) values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into SQLStatementsDemo(UserName) values('Bob'); Query ... Read More
To get the last element of array in MongoDB, use the following syntaxdb.yourCollectionName.find({}, {yourArrayFieldName:{$slice:-1}});Let us first create a collection with documents>db.getLastElementOfArrayDemo.insertOne({"StudentName":"James", "StudentMathScore":[78, 68, 98]}); { "acknowledged" : true, "insertedId" : ObjectId("5c9d2d71a629b87623db1b2e") } >db.getLastElementOfArrayDemo.insertOne({"StudentName":"Chris", "StudentMathScore":[88, 56, 34]}); { "acknowledged" : true, "insertedId" : ObjectId("5c9d2d83a629b87623db1b2f") } >db.getLastElementOfArrayDemo.insertOne({"StudentName":"Larry", "StudentMathScore":[99]}); { "acknowledged" : true, "insertedId" : ObjectId("5c9d2d8ea629b87623db1b30") } >db.getLastElementOfArrayDemo.insertOne({"StudentName":"Robert", "StudentMathScore":[90, 78, 67, 66, 75, 73]}); { "acknowledged" : true, "insertedId" : ObjectId("5c9d2dada629b87623db1b31") }Following is the query to display all documents from a collection with the help of find() method> db.getLastElementOfArrayDemo.find().pretty();This will produce the following output{ ... Read More