Anvi Jain has Published 569 Articles

What is the Java equivalent to MySQL's smallint?

Anvi Jain

Anvi Jain

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

2K+ Views

The short is equivalent to MySQL’s small int. The Java short takes 2 bytes that has the range -32768 to 32767 while MySQL smallint also take 2 bytes with same range.Here is the demo code of short in Java −public class SmallIntAsShortDemo {    public static void main(String[] args) { ... Read More

Delete the first 10 characters from JTextArea in Java

Anvi Jain

Anvi Jain

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

450 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

589 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

6K+ 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

207 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

1K+ 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

261 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

738 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

1K+ 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

MongoDB query to replace value with aggregation?

Anvi Jain

Anvi Jain

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

477 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