Anvi Jain has Published 629 Articles

Delete the first 10 characters from JTextArea in Java

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

311 Views

Let’s say the following is our JTextArea with default text −JTextArea textArea = new JTextArea("The text added here is just for demo. "    + "This demonstrates the usage of JTextArea in Java. In this example we have"    + "deleted some text.");Now to remove the first 10 characters, use ... Read More

How to delete multiple documents in MongoDB using deleteMany()?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

477 Views

Let us first create a collection with documents −> db.deleteMultipleDocumentsDemo.insertOne({"StudentFirstName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce00b07bf3115999ed51214") } > db.deleteMultipleDocumentsDemo.insertOne({"StudentFirstName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce00b0bbf3115999ed51215") } > db.deleteMultipleDocumentsDemo.insertOne({"StudentFirstName":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce00b0fbf3115999ed51216") } > db.deleteMultipleDocumentsDemo.insertOne({"StudentFirstName":"Bob"}); {    "acknowledged" : ... Read More

How to Read data from BLOB and CLOB type columns from a table using JDBC?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

5K+ Views

Clob datatypeCLOB stands for Character Large Object. in general, an SQL Clob is a built-in datatype which is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters. MYSQL database provides support Clob datatype TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT.The ... Read More

How to aggregate array documents in MongoDB?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

145 Views

For this, use the aggregate framework. Let us first create a collection with documents −> db.aggregateArrayDemo.insertOne(    {       "_id":100,       "UserDetails": [          {             "UserName": "John",             "UserLoginYear":2010       ... Read More

How to get the list of all drivers registered with the DriverManager using JDBC?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

844 Views

The java.sql.DriverManager class manages JDBC drivers in your application. This class maintains a list of required drivers and load them whenever it is initialized.Therefore, you need to register the driver class before using it. However, you need to do it only once per application.One way to register a driver class ... Read More

Java Program to replace the first 10 characters in JTextArea

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

199 Views

To replace the first 10 character in text area, use the replaceRange() method in Java and replace the old text with the new text.Let’s say the following is oude demo text set with JTextArea −JTextArea textArea = new JTextArea("This is a text displayed for our example. We have replaced some ... Read More

Perform multiplication in SELECT depending on column value in MySQL?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

647 Views

You can use CASE statement for this. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value1 int,    Value2 int    ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command ... Read More

How to make a background 25% transparent on iOS

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

928 Views

Apple provides backgroundColor which is an instance property, Changes to this property can be animated. The default value is nil, which results in a transparent background color.To make background 25% transparent we should  set the view to the UIColor with alpha 0.25view.backgroundColor = UIColor(white: 1, alpha: 0.25)You can write the following ... Read More

Java Program to get text from JTextPane and display in Console

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

581 Views

To get text from JTextPane, use the getText() method. At first, create a text pane component −JTextPane textPane = new JTextPane();Now, get the text −textPane.getText()); Display in Console: System.out.println(textPane.getText());The following is an example to get JTextPane and display in Console −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.JFrame; ... Read More

MongoDB query to replace value with aggregation?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

387 Views

Use aggregate framework along with $literal operator. Let us first create a collection with documents −> db.replaceValueDemo.insertOne(    {       _id : 100,       "EmployeeName" :"Chris",       "EmployeeOtherDetails": {          "EmployeeDesignation" : "HR",          "EmployeeAge":27       ... Read More

Advertisements