Nishtha Thakur

Nishtha Thakur

398 Articles Published

Articles by Nishtha Thakur

Page 20 of 40

How to set the initial value of an auto-incremented column in MySQL using JDBC?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.In MySQL database you can declare a column auto increment using the following syntax.CREATE TABLE table_name(    ID INT PRIMARY KEY AUTO_INCREMENT,    column_name1 data_type1,    column_name2 data_type2,    column_name3 data_type3,    column_name4 data_type4,    ............ ........... );While inserting records in a table there is no need to insert value under the auto-incremented column. These will be generated automatically.Setting the initial valueBy default, the initial value of the auto-incremented column will be 1. You ...

Read More

Returning multiple values from a function using Tuple and Pair in C++

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 3K+ Views

In C or C++, we cannot return more than one value from a function. To return multiple values, we have to provide output parameter with the function. Here we will see another approach to return multiple value from a function using tuple and pair STL in C++.The Tuple is an object capable to hold a collection of elements, where each element can be of different types.The pair can make a set of two values, which may be of different types. The pair is basically a special type of tuple, where only two values are allowed.Let us see one example, where ...

Read More

Can MongoDB return result of increment?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 159 Views

Yes, you can achieve this with findAndModify(). Let us first create a collection with documents −> db.returnResultOfIncementDemo.insertOne({"PlayerScore":98}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3c292edc6604c74817cda") }Following is the query to display all documents from a collection with the help of find() method −> db.returnResultOfIncementDemo.find();This will produce the following output −{ "_id" : ObjectId("5cd3c292edc6604c74817cda"), "PlayerScore" : 98 }Following is the query to return result of increment. Here, we have incremented PlayerScore by 2 −> db.returnResultOfIncementDemo.findAndModify({ ...   query:{}, ...   update: { $inc: {PlayerScore: 2 }}, ...   new: true ... });This will produce the following output −{ "_id" : ...

Read More

How to set values to list of parameters of IN clause on PreparedStatement using JDBC?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 4K+ Views

The IN clause in MYSQL database is used to specify the list of parameters in a query.For example, you need to retrieve contents of a table using specific IDs you can do so using the SELECT statement along with the IN clause as −mysql> SELECT * from sales where ID IN (1001, 1003, 1005); +------+-------------+--------------+--------------+--------------+-------+------------+ | ID   | ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location | +------+-------------+--------------+--------------+--------------+-------+------------+ | 1001 | Key-Board   | Raja         | 2019-09-01   | 11:00:00 | 8500 | Hyderabad ...

Read More

How to check if a field in MongoDB is [] or {}?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 201 Views

To check if a field in MongoDB is [] or {}, you can use the following syntax −db.yourCollectionName.find({    "yourOuterFieldName": { "$gt": {} },    "yourOuterFieldName.0": { "$exists": false } });Let us first create a collection with documents -> db.checkFieldDemo.insert([ ...   { _id: 1010, StudentDetails: {} }, ...   { _id: 1011, StudentDetails: [ { StudentId: 1 } ] }, ...   { _id: 1012, StudentDetails: [ {} ] }, ...   { _id: 1013 }, ...   { _id: 1014, StudentDetails: null}, ...   { _id: 1015, StudentDetails: { StudentId: 1 } } ... ]); BulkWriteResult({    "writeErrors" ...

Read More

Extending namespace and Unnamed namespace

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 369 Views

Here we will see how we can extend some namespace, and how the unnamed or anonymous name space can be used.Sometimes we can define one namespace. Then we can write the namespace again with the same definition. If the first one has some member, and second one has some other members, then the namespace is extended. We can use all of the members from that namespace.Example#include using namespace std; namespace my_namespace {    int my_var = 10; } namespace my_namespace { //extending namespace    int my_new_var = 40; } main() {    cout

Read More

How to change notification background colour in Android?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

This example demonstrate about How can I marquee the text content in Android Notification.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to res/layout/custom_notification_layout.xml.             Step 4 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.RemoteViews ; public class MainActivity ...

Read More

MongoDB pull with positional operator?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 220 Views

Use $pull operator along with positional operator($) in MongoDB. Let us first create a collection with documents −> db.pullWithPositionalOperatorDemo.insertOne( ...   { ...      _id: 100, ...      "StudentDetails": [ ...         { ...            "StudentId": "STU-1", ...            "StudentFavouriteSubject": ["MongoDB", "Java"] ...         }, ...         { ...            "StudentId": "STU-2", ...            "StudentFavouriteSubject": ["PHP", "MySQL"] ...         } ...      ] ...   } ... ); { ...

Read More

How to store decimal values in a table using PreparedStatement in JDBC?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 1K+ Views

To insert records into a table that contains a decimal value using PreparedStatement you need to −Register the driver − Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection − Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement − Create a PreparedStatement object using the prepareStatement() method of the Connection interface. Pass the INSERT query with place holders to this method in String format as a parameter.PreparedStatement pstmt = con.prepareStatement("INSERT ...

Read More

Hiding of all overloaded methods in base class in C++

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 622 Views

In C++, we can use the function overloading techniques. But if some base class has one method in overloaded form (different function signature with the same name), and the derived class redefines one of the function which is present inside the base, then all of the overloaded version of that function will be hidden from the derived class.Let us see one example to get the clear idea.Example#include using namespace std; class MyBaseClass {    public:       void my_function() {          cout

Read More
Showing 191–200 of 398 articles
« Prev 1 18 19 20 21 22 40 Next »
Advertisements