Java DatabaseMetaData supportsSavepoints() method with example

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

28 Views

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

How to concatenate results in MongoDB?

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

216 Views

You can concatenate results with the help of forEach(). Let us first create a collection with documents −> db.concatenateDemo.insertOne({"Name":"John", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc80dd88f9e6ff3eb0ce448") } > db.concatenateDemo.insertOne({"Name":"Carol", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc80de18f9e6ff3eb0ce449") }Following is the query to display all documents from a collection with the help of find() method −> db.concatenateDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cc80dd88f9e6ff3eb0ce448"),    "Name" : "John",    "Age" : 21 } {    "_id" : ObjectId("5cc80de18f9e6ff3eb0ce449"),    "Name" : "Carol",    "Age" : 23 }Here is the query to concatenate results ... Read More

C++ Program to Find the Number of Permutations of a Given String

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

1K+ Views

We can arrange the characters of a string in different order. Here we will see how we can count the number of permutations can be formed from a given string.We know that if one string is ‘abc’. It has three characters; we can arrange them into 3! = 6 different ways. So a string with n characters, we can arrange them into n! different ways. But now if there are same characters are present for multiple times, like aab, then there will not be 6 permutations.abaaabbaabaaaababaHere the (1, 6), (2, 5), (3, 4) are same. So here the number of ... Read More

How to customize how a JTabbedPane looks in Java?

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

563 Views

To customize how a JTabbedPane looks, change its font style, font face, font size and the background and foreground colors.Let’s say the following is the JTabbedPane −JTabbedPane tabbedPane = new JTabbedPane();Now, let us customize the above created JTabbedPane −tabbedPane.setBackground(Color.orange); tabbedPane.setForeground(Color.white); Font font = new Font("Verdana", Font.CENTER_BASELINE, 18); tabbedPane.setFont(font);The following is an example to customize JTabbedPane −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Technologies");       JTabbedPane tabbedPane = new JTabbedPane();       JPanel panel1, panel2, panel3, panel4, panel5;       ... Read More

Display MongoDB records by ObjectId?

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

75 Views

Let us first create a collection with documents −> db.findByObjectIdDemo.insertOne({"ClientName":"Larry", "ClientAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cd657806ebf1256f11a") } > db.findByObjectIdDemo.insertOne({"ClientName":"Chris", "ClientAge":26}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cdc57806ebf1256f11b") } > db.findByObjectIdDemo.insertOne({"ClientName":"David", "ClientAge":38, "isMarried":true}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cf657806ebf1256f11c") }Following is the query to display all documents from a collection with the help of find() method −> db.findByObjectIdDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd68cd657806ebf1256f11a"),    "ClientName" : "Larry",    "ClientAge" : 23 } {    "_id" : ObjectId("5cd68cdc57806ebf1256f11b"),    "ClientName" : "Chris",    "ClientAge" : 26 } { ... Read More

HTML autocomplete Attribute

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

164 Views

The autocomplete attribute of the element allows you to set whether the autocomplete for the input should be on or off. The web browser automatically fills the values if autocomplete is on. This only happens if the user already entered values before.Following is the syntax −Above,  on | off values are to be set for autocomplete to appear or not. Set on if you want the browser to complete the entries based on previously entered values, whereas off doesn’t allow to complete the entries.Let us now see an example to implement the autocomplete attribute of the element −Example Live Demo ... Read More

What is the difference between del, remove and pop on lists in python ?

Sri
Sri
Updated on 30-Jul-2019 22:30:26

416 Views

It does't matter how many lines of code you write in a program. When you want to remove or delete any elements from the Python list, you have to think about the difference between remove, del and pop in Python List and which one to useremove : remove() removes the first matching value or object, not a specific indexing. lets say list.remove(value)Examplelist=[10, 20, 30, 40] list.remove(30) print(list)Output[10, 20, 40]del : del removes the item at a specific index. lets say del list[index]Examplelist = [10, 20, 30, 40, 55] del list[1] print(list)Output[10, 30, 40, 55]pop : pop removes the item at a specific index and returns ... Read More

What are the rules to be followed while using varargs in java?

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

216 Views

Since JSE1.5 you can pass a variable number of values as argument to a method. These arguments are known as var args and they are represented by three dots (…)Syntaxpublic myMethod(int ... a) { // method body }Rules to follow while using varargs in JavaWe can have only one variable argument per method. If you try to use more than one variable arguments a compile time error is generated.ExampleIn the following Java example we are trying to accepts two varargs from the method sample().public class VarargsExample{ void demoMethod(int... ages), String... names) { ... Read More

In how many ways can we find a substring inside a string in javascript?

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

63 Views

We can find a substring inside a string in two ways. One way is using the indexOf() method and the other is using ES6 includes() method. let's discuss them in detail.indexOf()syntaxindexOf(str);This method tries to check the index of the substring we need. If there is index, which means substring is present, then true will be displayed in the output else false will be displayed as output. This method is case sensitive. ExampleLive Demo var company = "Tutorix"; document.write(company.indexOf('Tutor') !== -1); document.write(""); document.write(company.indexOf('tutor') !== -1); Outputtrue falseincludes()syntaxincludes(str);Unlike the indexOf() ... Read More

Print N lines of numbers such that every pair among numbers has a GCD K

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

110 Views

GCDGCD stands for Greatest Common Divisor of two or more integers excluding 0Like, to find the greatest common divisor of 48 and 18048 = 2 × 2 × 2 × 2 × 3180 = 2 × 2 × 3 × 3 × 5Greatest common divisor = 2 × 2 × 3 = 12.In the given problem, N lines should be printed with elements have GCD as specifiedInput : N=2 GCD=2 Ouput : 2-4-6-10 14-16-18-22AlgorithmSTART Step 1 -> take input n(e.g. 2) and k(e.g. 2) as int values and i Step 2-> Loop For i to 0 and i end loop ... Read More

Advertisements