Java DatabaseMetaData getDefaultTransactionIsolation() method with example

Arushi
Updated on 30-Jul-2019 22:30:26
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

How to store time created in a MySQL table?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26
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

How to add ScrollBar to JList in Java?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26
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

How to implement Polymorphism in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26
PolymorphismPolymorphism is one of the tenets of Object Oriented Programming (OOP). It helps to design objects in such a way that the they can share or override any behavior with the specific provided objects. Polymorphism takes advantage of inheritance in order to make this happen.In the following example child objects such as 'cricket' and 'tennis' have overridden the 'select' method called from parent object 'game' and returned a new string respectively as shown in the output. Whereas another child object 'football', instead of overriding the select method, shared(inherited) the method and displayed the parent string as shown in the output.ExampleLive Demo   ... Read More

Replace an array field value with MongoDB?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26
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

HTML <center> Tag

Chandu yadav
Updated on 30-Jul-2019 22:30:26
The center tag in HTML is used to center align text.Note: The tag isn’t supported in HTML5. CSS usage is suggested.Let us now see an example to implement the center tag in HTML −Example Live Demo table, th, td {    border: 2px solid blue; }    Table to calculate the budget    Expenses           Domains       Cost               Product Development       500000               Marketing       500000               Services       100000               Support       100000               Maintenance       100000               Total Budget = INR 1300000     Output

What is narrowing in java? Explain.

Venkata Sai
Updated on 30-Jul-2019 22:30:26
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

MySQL query to find all rows where string contains less than four characters?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26
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

C Program to Add two Integers

Sharon Christine
Updated on 30-Jul-2019 22:30:26
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 \n", 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

C++ Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers

Samual Sam
Updated on 30-Jul-2019 22:30:26
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
Advertisements