Vikyath Ram

Vikyath Ram

96 Articles Published

Articles by Vikyath Ram

Page 9 of 10

Java DatabaseMetaData getIdentifierQuoteString() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 384 Views

The getIdentifierQuoteString() method of the DatabaseMetaData interface retrieves and returns the retrieves the string used by the underlying database to quote SQL identifiers.To retrieve the string used by the underlying database to quote SQL identifiers.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 ...

Read More

Java DatabaseMetaData getSQLKeywords() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 344 Views

This method retrieves the list of all the SQL keywords of the underlying database and returns in the form of a String variable which holds all the keywords separated by commas.To get the list of keywords in 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 ...

Read More

Java DatabaseMetaData getUserName() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 1K+ Views

This method retrieves the user name used to establish the current connection −To retrieve the user name as known to 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 getMetaData() method of the Connection interface.Finally, retrieve the ...

Read More

Java ResultSet getRow() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 8K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The getRow() method of the ResultSet interface retrieves the current row number/position of the ResultSet pointer.This method returns an integer value representing the current row number to which the ResultSet pointer points to.ExampleLet us ...

Read More

Use boolean value to stop a thread in Java

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 1K+ Views

A thread can be created by implementing the Runnable interface and overriding the run() method. Then a Thread object can be created and the start() method called.A thread can be stopped using a boolean value in Java. The thread runs while the boolean value stop is false and it stops running when the boolean value stop becomes true.A program that demonstrates this is given as follows:Exampleclass ThreadDemo extends Thread {    public boolean stop = false;    int i = 1;    public void run() {       while (!stop) {          try {     ...

Read More

Use a character class in Java Regular Expressions

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 216 Views

A character class is set of characters that are enclosed inside square brackets. The characters in a character class specify the characters that can match with a character in an input string for success. An example of a character class is [a-z] which denotes the alphabets a to z.A program that demonstrates a character class in Java Regular Expressions is given as follows:Example Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo {    public static void main(String args[]) {       Pattern p = Pattern.compile("[a-z]+");       Matcher m = p.matcher("the sky is blue");       System.out.println("The input ...

Read More

Deriving a Class in Java

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 4K+ Views

A class can be derived from the base class in Java by using the extends keyword. This keyword is basically used to indicate that a new class is derived from the base class using inheritance. It can also be said that it is used to extend the functionality of the class.A program that demonstrates this is given as follows:Example Live Democlass A {    void funcA() {       System.out.println("This is class A");    } } class B extends A {    void funcB() {       System.out.println("This is class B");    } } public class Demo {   ...

Read More

Variable in subclass hides the variable in the super class in Java

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 491 Views

Sometimes the variable in the subclass may hide the variable in the super class. In that case, the parent class variable can be referred to using the super keyword in Java.A program that demonstrates this is given as follows:Example Live Democlass A {    char ch; } class B extends A {    char ch;    B(char val1, char val2) {       super.ch = val1;       ch = val2;    }    void display() {       System.out.println("In Superclass, ch = " + super.ch);       System.out.println("In subclass, ch = " + ch);    } ...

Read More

Make a class final in Java

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 5K+ Views

A class can be made final by using the final keyword. The final class cannot be inherited and so the final keyword is commonly used with a class to prevent inheritance.A program that demonstrates a final class in Java is given as follows:Example Live Demofinal class A {    private int a = 15;    public void printA() {       System.out.println("Value of a = " + a);    } } public class Demo {    public static void main(String args[]) {       A obj = new A();       obj.printA();    } }OutputValue of a = ...

Read More

How to import all classes in Java?

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 13K+ Views

All the classes in a package can be imported using the import statement along with the character *. For example - All the classes in the package java.util can be imported using import java.util.*;A program that demonstrates this in Java is given as follows:Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       Stack stack = new Stack();       stack.push("Apple");       stack.push("Mango");       stack.push("Guava");       stack.push("Pear");       stack.push("Orange");       System.out.println("The stack elements are: " + stack);    } }OutputThe stack elements ...

Read More
Showing 81–90 of 96 articles
« Prev 1 6 7 8 9 10 Next »
Advertisements