Java DatabaseMetaData supportsTransactions() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

50 Views

The supportsTransactions() method of the DatabaseMetaData interface is used to determine whether the underlying database supports transactions.This method returns a boolean value which is −True, when the underlying database supports stored procedures.False, when the underlying database doesn't support stored procedures.To determine whether the underlying database supports stored procedures−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 ... Read More

what is the main difference between '=' and '==' operators in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

139 Views

The use of  "=" operator is that it assigns value from right to left, whereas "==" shows whether the given values are equal or not.In the following example variables x and y were assigned values using "=" operator and their magnitudes were checked using "==" operator.Example Live Demo    var x = 5;    var y = "6";    document.write(x);    document.getElementById("equal").innerHTML =    (x == y); Outputfalse 5

What are all the common undefined behaviours that a C++ programmer should know about?

George John
Updated on 30-Jul-2019 22:30:26

79 Views

In C++, there are some undefined behaviors. These are identified by doing some tasks in C++. There are no such direct definitions. These few things should be known to all of the programmers, who want to use C++ for different purposes.Here we will see some C++ Codes. and try to guess the results. The codes will generate some runtime errors.The Divide By Zero error is undefined.Example Code#include using namespace std; int main() {    int x = 10, y = 0;    int z = x / y;    cout

Add multiple number input fields with JOptionPane and display the sum in Console with Java

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

At first, set multiple number input fields −JTextField text1 = new JTextField(10); JTextField text2 = new JTextField(10); JTextField text3 = new JTextField(10); JTextField text4 = new JTextField(10); JTextField text5 = new JTextField(10); JTextField text6 = new JTextField(10); JTextField text7 = new JTextField(10); JTextField text8 = new JTextField(10); panel.add(text1); panel.add(text2); panel.add(text3); panel.add(text4); panel.add(text5); panel.add(text6); panel.add(text7); panel.add(text8);Now, let us add the values of the multiple number input fields created above −System.out.println(Integer.parseInt(text1.getText()) + Integer.parseInt(text2.getText()) +    Integer.parseInt(text3.getText())+ Integer.parseInt(text4.getText())+    Integer.parseInt(text5.getText())+ Integer.parseInt(text6.getText())+    Integer.parseInt(text7.getText())+ Integer.parseInt(text8.getText()));Above, we have displayed the sum in the Console.The following is an example to sum multiple number input fields with ... Read More

How do I avoid the variable value in a MySQL stored procedure to change when records are updated?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

132 Views

We will create a stored procedure that does not change the variable value whenever the value is updated.Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value int    ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values(100); Query OK, 1 row affected (0.13 sec) Display all records from the table using select statement : mysql> select *from DemoTable;Output+----+-------+ | Id | Value | +----+-------+ | 1 | 100 | +----+-------+ 1 row ... Read More

HTML Charset

George John
Updated on 30-Jul-2019 22:30:26

195 Views

Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters. The charset attribute in HTML is used with the to specify the character encoding.Following is the syntax −Above, char_set is the character set to specify the character encoding of an HTML document. Let us now see an example to implement HTML character encoding −Example Live Demo Example We have added demo text −    Here, we are mentioned the demo content. This is just to display an example of charset in an HTML document.    Previous    Next Output

What are the rules to be followed while making a variable static and final?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

227 Views

Static variables − Static variables are also known as class variables. You can declare a variable static using the keyword. Once you declare a variable static there would only be one copy of it in the class, regardless of how many objects are created from it.public static int num = 39;final − Once you declare a variable final you cannot reassign value to it. When you declare a variable of a class static and final we are making it constant.Rules to be followedInitialization is mandatory − It is not mandatory to initialize the instance variables of a class in java. ... Read More

Absolute Difference of all pairwise consecutive elements in an array (C++)?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

390 Views

In this problem we will see how we can get the absolute differences between the elements of each pair of elements in an array. If there are n elements, the resultant array will contain n-1 elements. Suppose the elements are {8, 5, 4, 3}. The result will be |8-5| = 3, then |5-4| = 1, |4-3|=1.AlgorithmpairDiff(arr, n)begin    res := an array to hold results    for i in range 0 to n-2, do       res[i] := |res[i] – res[i+1]|    done endExample Live Demo#include #include using namespace std; void pairDiff(int arr[], int res[], int n) {    for ... Read More

Print the given pattern recursively

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here, as per the given problem pattern needs to be displayed using recursive approach.Recursive function is the one that calls itself n number of times. There can be ‘n’ number of recursive function in a program. The problem working with recursive function is their complexity.AlgorithmSTART Step 1 -> function int printpattern(int n)    If n>0       Printpattern(n-1)       Print *    End IF End Step 2 -> function int pattern(int n)    If n>0       pattern(n-1)    End IF    Printpattern(n)    Print End STOPExample#include int printpattern(int n) {    if(n>0) { ... Read More

How to check if input is numeric in C++?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see how to check whether a given input is numeric string or a normal string. The numeric string will hold all characters that are in range 0 – 9. The solution is very simple, we will simply go through each characters one by one, and check whether it is numeric or not. If it is numeric, then point to the next, otherwise return false value.Example#include using namespace std; bool isNumeric(string str) {    for (int i = 0; i < str.length(); i++)       if (isdigit(str[i]) == false)          return false; //when ... Read More

Advertisements