Java ResultSetMetaData getColumnType() method with example

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

4K+ Views

The getColumnType() method of the ResultSetMetaData (interface) retrieves the type of the specified column in the current ResultSet object.This method accepts an integer value representing the index of a column and, returns an integer value representing the SQL type of the specified column.Following is the list of values returned by various datatypes of java.sql.Type −Array: 2003Big int: -5Binary: -2Bit: -7Blob: 2004Boolean: 16Char: 1Clob: 2005Date: 91Datalink70Decimal: 3Distinct: 2001Double: 8Float: 6Integer: 4JavaObject: 2000Long var char: -16Nchar: -15NClob: 2011Varchar: 12VarBinary: -3Tiny int: -6Time stamt with time zone: 2014Timestamp: 93Time: 92Struct: 2002SqlXml: 2009Smallint: 5Rowid: -8Refcursor: 2012Ref: 2006Real: 7Nvarchar: -9Numeric: 2Null: 0Smallint: 5To get the ResultSetMetaData ... Read More

How do I change a MongoDB user's password?

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

956 Views

You need to use changeUserPassword() to change a user’s password. Let us first create a user with some roles. Following is the query to create a user in MongoDB −> use admin switched to db admin > db.createUser( ...    { ...       user: "Chris", ...       pwd: "chris", ...       roles: [ { role: "readWrite", db: "test" } ] ...    } ... ); Successfully added user: {    "user" : "Chris",    "roles" : [       {          "role" : "readWrite",          "db" : ... Read More

How can Detached DOM elements cause memory leak in JavaScript?

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

2K+ Views

Detached Dom elementsDetached DOM elements are the elements which have been removed from the DOM but their memory is still retained because of JavaScript. This means that as long the element have a reference to any variable or an object anywhere, it does not garbage collected even after destroyed from the DOM.DOM is like an double-linked tree which means a reference to a node in the tree will halt the entire tree from garbage collection.Let's take an example of creating a DOM element in javascript. After creating the element destroy it but forget to delete the variable holding it. This ... Read More

How do I push elements to an existing array in MongoDB?

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

272 Views

To push elements to an existing array, use $addToSet operator along with update(). Let us first create a collection with documents −> db.pushElements.insertOne({"Comments":["Good", "Awesome", "Nice"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd682597924bb85b3f48953") }Following is the query to display all documents from a collection with the help of find() method −> db.pushElements.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd682597924bb85b3f48953"),    "Comments" : [       "Good",       "Awesome",       "Nice"    ] }Following is the query to push elements to an existing array in MongoDB −> db.pushElements.update(    {_id:ObjectId("5cd682597924bb85b3f48953")},    { ... Read More

Shuffle vs random_shuffle in C++

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

326 Views

Here we will see the Shuffle and random_shuffle in C++. Let us see the random_shuffle first. It is used to randomly rearrange the elements in range [left, right). This function randomly swaps the positions of each element with the position of some randomly chosen positions.We can provide some random generator function to tell which element will be taken in every case. If we do not provide some, it will use its own random generator function.Example Live Demo#include using namespace std; int myRandomGenerator(int j) {    return rand() % j; } main() {    srand(unsigned(time(0)));    vector arr;    for (int ... Read More

What are the differences between length and length () in Java?\

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

3K+ Views

The length is an instance variable of an array in Java whereas length() is a method of String class.lengthAn array is an object that holds a fixed number of values of the same type.The length variable in an array returns the length of an array i.e. a number of elements stored in an array.Once arrays are initialized, its length cannot be changed, so the length variable can directly be used to get the length of an array.The length variable is used only for an array.ExampleLive Demopublic class ArrayLengthTest {    public static void main(String args[]) {       int ... Read More

HTML DOM Input FileUpload Object

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

224 Views

The HTML DOM input FileUpload Object represents the

1 to n bit numbers with no consecutive 1s in binary representation?

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

323 Views

In this problem, we have to find some binary numbers which have no consecutive 1s. In a 3-bit binary string, there are three binary numbers 011, 110, 111, who have consecutive 1s, and five numbers are there which have no consecutive 1s. So after applying this algorithm for 3-bit numbers, the answer will be 5.If a[i] be the set of binary numbers, whose number of bits are i, and not containing any consecutive 1s, and b[i] is the set of binary number, where number of bits are i, and containing consecutive 1s, then there are recurrence relations like −a[i] := ... Read More

Print Reverse a linked list using Stack

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

937 Views

Given with a linked list program must print the list starting from the end till the front using the stack data structureInput : 10 -> 5 -> 3 -> 1 -> 7 -> 9 Output: 9 -> 7 -> 1 -> 3 -> 5 -> 10Here the user can use the approach of poping elements from the stack pointing top at the stack[0] location and than going till stack[n] elementAlgorithmSTART Step 1 -> create structure Linked_list    Declare int data    Declare struct linked_list *next End Step 2 -> declare int stack[30], top = -1 Step 3 -> declare struct ... Read More

Get output of MongoDB shell script?

Samual Sam
Updated on 30-Jul-2019 22:30:26

664 Views

You can use printjson() or print() to get output of MongoDB shell script. Let us create an array of objects.Following is the query to create an array of objects.> var studentDetails=[{"StudentName":"John","StudentAge":21},    {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];Following is the query to get the output of Mongo shell script using printjson() −> printjson(studentDetails);This will produce the following output −[    {       "StudentName" : "John",       "StudentAge" : 21    },    {       "StudentName" : "Carol",       "StudentAge" : 24    },    {       "StudentName" : "David",       "StudentAge" : 25    } ] > var studentDetails=[{"StudentName":"John","StudentAge":21},    {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];

Advertisements