JDBC CLOB Data Type: Store and Read Data

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

11K+ Views

CLOB stands for Character Large Object in general, an SQL Clob is a built-in datatype and is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters.The java.sql.Clob interface of the JDBC API represents the CLOB datatype. Since the Clob object in JDBC is implemented using an SQL locator, it holds a logical pointer to the SQL CLOB (not the data).MYSQL database provides support for this datatype using four variables.TINYTEXT: A CLOB type with a maximum of 28-1 (255) characters.TEXT: A CLOB type with a maximum of 216-1 ... Read More

IntStream peek Method in Java

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

727 Views

The peek() method in the IntStream class in Java returns a stream consisting of the elements of this stream. It additionally performs the provided action on each element as elements are consumed from the resulting stream.The syntax is as followsIntStream peek(IntConsumer action)Here, the parameter action is a non-interfering action to perform on the elements as they are consumed from the stream. The IntConsumer represents an operation that accepts a single int-valued argument and returns no result.The following is an example to implement IntStream peek() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo { public static ... Read More

Decade Class in Java Tuples

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

125 Views

A Decade class is a Tuple with 10 elements. It is in the JavaTuples library. The following is the declaration −public final class Decade extends Tuple implements IValue0, IValue1 , IValue2, IValue3, IValue4, IValue5, IValue6, IValue7, IValue8, IValue9Let 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. ... Read More

Create and Release a Save Point in JDBC

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

975 Views

When you set a save point you define a logical rollback point within a transaction. If an error occurs past a save point, you can use the rollback method to undo either all the changes or only the changes made after the save point.Savepoint interface gives you the additional transactional control. Most modern DBMS, support save points within their environments such as Oracle's PL/SQL.Setting a save pointYou can set a save point in a database using the setSavepoint(String savepointName) method of the Connection interface, this method accepts a string value representing the name of the save point and returns a ... Read More

Use Apply in Android Shared Preferences with Example

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

479 Views

Before getting into shared preference apply(), we should know what is shared preferences in android. Using share preference, we can store or retrieve values as key and value pair. There are five different methods are available in share preference as shown below -Edit()- It going to edit shared preference valuescommit()- it going to commit shared preference values in xml fileapply()- It going to commit back changes from editor to shared preference.remove(String key)- It going to remove key and vales from shared preference use key.Put()- It going to put key and values to shared preference xml.A sample example syntax of shared ... Read More

Find All Documents in MongoDB with a Specific Field

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

133 Views

To use MongoDB to find all documents which have a field, regardless of the value of that field, use the $exists operator. Following is the syntaxdb.yourCollectionName.find({yourFieldName:{$exists:true}});Let us create a collection with documents>db.findAllDocumentWhichHaveFieldDemo.insertOne({"StudentName":"John", "StudentAge":null}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9d1d60a629b87623db1b22") } >db.findAllDocumentWhichHaveFieldDemo.insertOne({"StudentName":"Larry", "StudentAge":null}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9d1d70a629b87623db1b23") } >db.findAllDocumentWhichHaveFieldDemo.insertOne({"StudentName":"Chris", "StudentAge":""}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9d1d7ba629b87623db1b24") } >db.findAllDocumentWhichHaveFieldDemo.insertOne({"StudentName":"Robert", "StudentAge":""}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9d1d81a629b87623db1b25") }Following is the query to display all documents from a collection with the help of find() method> db.findAllDocumentWhichHaveFieldDemo.find().pretty();This will produce the following ... Read More

Select Table with Greatest Number of Columns in MySQL

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

127 Views

You can use INFORMATION_SCHEMA.COLUMNS to get the table with the greatest number of columns. The syntax is as follows −SELECT TABLE_NAME, COUNT(*) AS anyAliasName FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME ORDER BY yourAliasName DESC LIMIT 1;Following is the query to select the table that has the greatest number of columns. We are getting this result because we have set the count to DESC and used GROUP BY TABLE_NAME −mysql> SELECT TABLE_NAME, COUNT(*) as TOTAL_COUNT FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME ORDER BY TOTAL_COUNT DESC LIMIT 1;This will produce the following output −+-----------------------------------+-------------+ | TABLE_NAME                   ... Read More

Sort Array of Strings by Length in Java

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

321 Views

At first, let us create and array of strings:String[] strArr = { "ABCD", "AB", "ABCDEFG", "ABC", "A", "ABCDE", "ABCDEF", "ABCDEFGHIJ" }Now, for longest to shortest pattern, for example ABCDEFGHIJ, ABCDEFG, ABCDEF, etc.; get the length of both the string arrays and work them like this:Arrays.sort(strArr, (str1, str2) → str2.length() - str1.length());The following is an example to sort array of strings by their lengths with longest to shortest pattern in Java:Exampleimport java.util.Arrays; public class Demo {    public static void main(String[] args) {       String[] strArr = { "ABCD", "AB", "ABCDEFG", "ABC", "A", "ABCDE", "ABCDEF", "ABCDEFGHIJ" };     ... Read More

8085 Program to Perform Operation on Two Numbers Based on Contents of X

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

314 Views

Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to do different operations based on choice.Problem Statement:Write 8085 Assembly language program to perform some operations on two 8-bit binary numbers base on choice.Discussion:In this program we are taking a choice. The choice value is stored at memory location 8000H (named as X). And the numbers are stored at location 8001H and 8002H. We are storing the result at location 8050H and 8051H.Here if the choice is 00H, then it will perform addition, for 01H, it will perform subtraction, and for 02H, it ... Read More

Get Random Record from MongoDB

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

2K+ Views

To get a random record from MongoDB, you can use aggregate function. The syntax is as follows:db.yourCollectionName.aggregate([{$sample:{size:1}}]);To understand the above syntax, let us create a collection with some documents. The query to create collection is as follows:>db.employeeInformation.insert({"EmployeeId":1, "EmployeeName":"Maxwell", "EmployeeAge":26}); WriteResult({ "nInserted" : 1 }) >db.employeeInformation.insert({"EmployeeId":2, "EmployeeName":"David", "EmployeeAge":25}); WriteResult({ "nInserted" : 1 }) >db.employeeInformation.insert({"EmployeeId":3, "EmployeeName":"Carol", "EmployeeAge":24}); WriteResult({ "nInserted" : 1 }) >db.employeeInformation.insert({"EmployeeId":4, "EmployeeName":"Bob", "EmployeeAge":28}); WriteResult({ "nInserted" : 1 }) >db.employeeInformation.insert({"EmployeeId":5, "EmployeeName":"Sam", "EmployeeAge":27); WriteResult({ "nInserted" : 1 })Now you can display all documents from a collection with the help of find() method. The query is as follows:> db.employeeInformation.find().pretty();The following is the output:{ ... Read More

Advertisements