In a database system where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction.The getDefaultTransactionIsolation() method of the DatabaseMetaData interface returns the default isolation level of the underlying database in integer format.To know the default transaction isolation of the underlying database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of ... Read More
You can use DEFAULT CURRENT_TIMESTAMP. Keep in mind that it will work only at the time of insertion. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Arrivaltime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); Query OK, 0 rows affected (0.31 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Arrivaltime) values('2018-01-31 10:34:56'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Arrivaltime) values('2019-01-31 11:10:12'); Query OK, 1 row affected (0.04 sec)Display ... Read More
Let us first set a JList and add items −List myList = new ArrayList(10); for (int index = 0; index < 20; index++) { myList.add("List Item " + index); }Now, we will set the above list to a new list −final JList list = new JList(myList.toArray(new String[myList.size()]));Now, set the ScrollBar to JList −JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(list); list.setLayoutOrientation(JList.VERTICAL);The following is an example to add ScrollBar to JList −Examplepackage my; import java.awt.BorderLayout; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; public class SwingDemo { public static void main(String[] args) { JPanel ... Read More
You can use positional operator $. Let us first create a collection with documents −> db.replaceAnArrayFieldValueDemo.insertOne({"StudentTechnicalSubjects":["MySQL", "SQL Server", "PL/SQL"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cea41e0ef71edecf6a1f68f") }Following is the query to display all documents from a collection with the help of find() method −> db.replaceAnArrayFieldValueDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cea41e0ef71edecf6a1f68f"), "StudentTechnicalSubjects" : [ "MySQL", "SQL Server", "PL/SQL" ] }Following is the query to replace an array field value. Here, we are updating “SQL Server” with “MongoDB” −> db.replaceAnArrayFieldValueDemo.update( {"StudentTechnicalSubjects":"SQL Server"}, ... Read More
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) as listed below −boolean − Stores 1-bit value representing true or, false.byte − Stores twos compliment integer up to 8 bits.char − Stores a Unicode character value up to 16 bits.short − Stores an integer value upto 16 bits.int − Stores an integer value upto 32 bits.long − Stores an integer value upto 64 bits.float − Stores a floating point value upto 32bits.double − Stores a floating point value up to 64 bits.Converting one primitive data type into another is known as type ... Read More
Use CHAR_LENGTH() and find the count of characters in every string and then get the strings which are less than four characters. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (1.38 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected (1.60 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.25 ... Read More
A program to add two numbers takes to numbers and does their mathematical sum and gives it to another variable that stores its sum.Example Code Live Demo#include int main(void) { int a = 545; int b = 123; printf("The first number is %d and the second number is %d ", a , b); int sum = a + b; printf("The sum of two numbers is %d" , sum); return 0; }OutputThe first number is 545 and the second number is 123 The sum of two numbers is 668
This is a C++ Program to find k numbers closest to Median of S, where S is a set of n numbers.AlgorithmsBegin function partition() for partitioning the array on the basis of values at high as pivot value: Arguments: a[]=an array. l=low H=high Body of the function: Declare variables pivot, in, i Initialize in = l Set pivot = h For i=l to h-1 if(a[i] < a[pivot]) swap a[i] and a[in]) increment in. ... Read More
The getDriverMinorVersion() method of the DatabaseMetaData interface returns the minor version of the JDBC driver used.To get the minor version of the JDBC driver used to connect with the database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.Get the DatabaseMetaData object with respect to the current connection using the ... Read More
You can use elt() along with rand() for this. Let us select random number from a specific list.mysql> SELECT ELT(FLOOR(RAND() * 10) + 1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000) AS random_value_from_listOfValues;This will produce the following output −+--------------------------------+ | random_value_from_listOfValues | +--------------------------------+ | 1000 | +--------------------------------+ 1 row in set (0.00 sec)Now we will run the query again to select random number from a specific list.mysql> SELECT ELT(FLOOR(RAND() * ... Read More