Daniol Thomas has Published 242 Answers

What are the types of statements in JDBC?

Daniol Thomas

Daniol Thomas

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

There are three types of statements in JDBC namely, Statement, Prepared Statement, Callable statement.StatementThe Statement interface represents the static SQL statement. It helps you to create a general purpose SQL statements using Java.Creating a statementYou can create an object of this interface using the createStatement() method of the Connection interface.Create ... Read More

LongStream map() method in Java

Daniol Thomas

Daniol Thomas

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

The map() method of the LongStream class in Java returns a stream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows:LongStream map(LongUnaryOperator mapper)Here, the parameter mapper is a stateless function to apply to each element. The LongUnaryOperator represents an operation ... Read More

What are bind variables? How to execute a query with bind variables using JDBC?

Daniol Thomas

Daniol Thomas

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

A bind variable is an SQL statement with a temporary variable as place holders which are later replaced with appropriate values. For example, if you have a table named employee in the database created as shown below:+---------+--------+----------------+ | Name | Salary | Location ... Read More

How to write a JDBC program to extract data from multiple databases?

Daniol Thomas

Daniol Thomas

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

To connect with a data base, you need toRegister the DriverSelect the required database register the Driver class of the particular database using the registerDriver() method of the DriverManager class or, the forName() method of the class named Class.DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get connectionCreate a connection object by passing the URL of the ... Read More

How to drop a collection in MongoDB?

Daniol Thomas

Daniol Thomas

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

To drop a collection in MongoDB, you need to use drop() command. The syntax is as follows:db.yourCollectionName.drop();The above syntax returns true or false. It returns true if the collection is dropped successfully otherwise false.Let us first display all collection names from MongoDB. Here, we have a database ‘sample’ that contains ... Read More

C++ Program to Perform Greedy Coloring

Daniol Thomas

Daniol Thomas

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

Here is a C++ Program to Perform Greedy ColoringAlgorithm:Begin    Take the number of vertices and edges as input.    Create function greedyColoring() to assign color to vertices:    A) Assign the first color to first vertex.    B) Initialize the remaining vertices.    C) Declare a temporary array to ... Read More

C++ Program to Find Maximum Number of Edge Disjoint Paths

Daniol Thomas

Daniol Thomas

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

This is a C++ program to find Maximum Number of Edge Disjoint Paths which means shortest subset path or maximum flow between two vertices.Algorithms:Begin    function bfs() returns true if there is path from source s to sink t in    the residual graph which indicates additional possible flow in ... Read More

How to insert new documents into a MongoDB collection in your database?

Daniol Thomas

Daniol Thomas

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

To insert new documents into a MongoDB collection, you need to use insert() method or save() method.Case 1: Using insert() method.The syntax is as follows:db.yourCollectionName.insert(yourDocument);Case 2: Using save() method.The syntax is as follows:db.yourCollectionName.save(yourDocument);In the above syntax, if your collection name does not exist then MongoDB will create a new collection ... Read More

C++ Program to Perform Operations in a BST

Daniol Thomas

Daniol Thomas

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

         A Binary Search Tree is a sorted binary tree in which all the nodes will have following properties−The right sub-tree of a node has a key greater than to its parent node's key.The left sub-tree of a node has a key lesser than to its parent ... Read More

How to update or modify the existing documents of a collection in MongoDB?

Daniol Thomas

Daniol Thomas

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

To update or modify the existing documents of a collection in MongoDB, you need to use update() method. The syntax is as follows:db.yourCollectionName.update(yourExistingValue, yourUpdatedValue);Here, we will create a collection with name updateinformation. The query to create a collection is as follows. MongoDB creates a collection automatically when you insert some ... Read More

Advertisements