- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
A save point is a logical rollback point within a transaction. When you set a save point, whenever an error occurs past a save point, you can undo the events you have done up to the save point using the rollback() method.You can set a save point in a database using the setSavepoint(String savepointName) method of the Connection interface.//Setting the save point Savepoint savePoint = con.setSavepoint("MysavePoint");This method accepts a string value representing the name of the save point and, returns a save point object.To set a save point −Register the driver using the registerDriver() method of the DriverManager class as −//Registering ... Read More
Yes, you can achieve this using aggregate framework. Let us first create a collection with documents −> db.sliceOfSliceDemo.insertOne( ... { ... "Name": "John", ... "Details": [["First 1:1", "First 1:2"], ["second 2:1", "Second 2:2"]] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5ccf3fcfdceb9a92e6aa195a") }Following is the query to display all documents from a collection with the help of find() method −> db.sliceOfSliceDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5ccf3fcfdceb9a92e6aa195a"), "Name" : "John", "Details" : [ [ "First ... Read More
A thread-safe class is a class that guarantees the internal state of the class as well as returned values from methods, are correct while invoked concurrently from multiple threads.The HashMap is a non-synchronized collection class. If we need to perform thread-safe operations on it then we must need to synchronize it explicitly.Example:import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Iterator; public class HashMapSyncExample { public static void main(String args[]) { HashMap hmap = new HashMap(); hmap.put(2, "Raja"); hmap.put(44, "Archana"); hmap.put(1, "Krishna"); ... Read More
Use the getChildCount() method in Java to get the count of child nosed of any node i.e. even if it’s a root node or not.Let’s say we want the count of child nodes for node 1, which is not a root node, therefore −node1.getChildCount()The following is an example to get the count of child nodes of any node −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Demo"); DefaultMutableTreeNode node = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node1 ... Read More
For this, you can use COLLATE. Following is the syntax −select *from yourTableName where yourColumnName LIKE yourValue COLLATE utf8_bin;Let us first create a table −mysql> create table DemoTable ( LastName varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Brown'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('BROWN'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('BRoWN'); Query OK, 1 row affected (0.14 sec)Display all records ... Read More
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting. There are two types of casting −Widening− Converting a lower datatype to a higher datatype is known as widening. It is done implicitly.Narrowing− Converting a higher datatype to a lower datatype is known as narrowing. You need to do it explicitly using the cast operator (“( )”).For every primitive variable a wrapper class is available, ... Read More
Here we will see how we can concatenate a string n number of times. The value of n is given by the user. This problem is very simple. In C++ we can use + operator for concatenation. Please go through the code to get the idea.AlgorithmconcatStrNTimes(str, n)begin res := empty string for i in range 1 to n, do res := concatenate res and res done return res endExample Live Demo#include using namespace std; main() { string myStr, res = ""; int n; cout > myStr; cout > n; for(int i= 0; i < n; i++) { res += myStr; } cout
The Location port property returns/sets the port number (if specified) for a URL. Port number might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the port propertylocation.portValue of the port property setlocation.port = portNumberExampleLet us see an example for Location port property − Live Demo Location port form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ... Read More
Here we will see three functions. These functions are Rint(), rintf() and the rintl(). These functions are used to convert floating point values into rounded format.The rint() FunctionThis function is used for rounding floating point value to integer. The syntax is like below. If the result is outside of return type, the domain error may occur. When the argument is 0 or infinity, then it will return unmodifiedfloat rint(float argument) double rint(double argument) long double rint(long double argument)Example#include #include using namespace std; main() { double a, b, x, y; x = 53.26; y = 53.86; ... Read More
Here we will see how to generate random number in given range using C. To solve this problem, we will use the srand() function. The current time will be used to seed the srad() function.This function cannot generate random number in any range, it can generate number between 0 to some value. So for it, we have to follow one trick. We will generate random number in between 0 to (upper – lower + 1), then add the lower limit for offsetting.Example#include #include #include void generate_random(int l, int r, int count) { //this will generate random number ... Read More
To Continue Learning Please Login
Login with Google