When to Use Each of the 4 JDBC Driver Types

Nancy Den
Updated on 30-Jul-2019 22:30:25

179 Views

If you are accessing one type of database, such as Oracle, Sybase, or IBM, the preferred driver type is 4.If your Java application is accessing multiple types of databases at the same time, type 3 is the preferred driver.Type 2 drivers are useful in situations, where a type 3 or type 4 driver is not available yet for your database.The type 1 driver is not considered a deployment-level driver, and is typically used for development and testing purposes only.

Use equalsIgnoreCase in Android TextView

Smita Kapse
Updated on 30-Jul-2019 22:30:25

468 Views

This example demonstrate about How to use equalsIgnoreCase () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             In the above code, we have taken name as Edit text, when user click on button it will take data and check that given string contains “point”.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import ... Read More

Get Long Value of MonthDay in Java

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

89 Views

The long value of a specified Chronofield can be obtained using the getLong() method in the MonthDay class in Java. This method requires a single parameter i.e. the ChronoField and it returns the long value of a specified Chronofield.A program that demonstrates this is given as followsExample Live Demoimport java.util.*; import java.time.*; import java.time.temporal.ChronoField; public class Demo {    public static void main(String[] args) {       MonthDay md = MonthDay.parse("--02-22");       System.out.println("The MonthDay is: " + md);       System.out.println("The MONTH_OF_YEAR is: " +       md.getLong(ChronoField.MONTH_OF_YEAR));    } }OutputThe MonthDay is: --02-22 The MONTH_OF_YEAR ... Read More

Instant minusSeconds Method in Java

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

194 Views

An immutable copy of a instant where some seconds are subtracted from it can be obtained using the minusSeconds() method in the Instant class in Java. This method requires a single parameter i.e. the number of seconds to be subtracted and it returns the instant with the subtracted seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("The current instant is: " + i);       System.out.println("An instant with 10 seconds subtracted is: " + ... Read More

Get Maximum Value from 3 Different Columns in MySQL

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

7K+ Views

To get the maximum value from three different columns, use the GREATEST() function.The syntax is as followsSELECT GREATEST(yourColumnName1, yourColumnName2, yourColumnName3) AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table MaxOfThreeColumnsDemo    -> (    -> First int,    -> Second int,    -> Third int    -> ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into MaxOfThreeColumnsDemo values(30, 90, 60); Query OK, 1 row affected (0.16 sec) mysql> insert into MaxOfThreeColumnsDemo values(100, ... Read More

Insert Record from One Mongo Database to Another

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

532 Views

You can switch from one database to another using the use command. Here, we are using the collection in the “test” database. Let us insert that collection in another database with the name “sample”.To understand further, let us create a collection with the document. The query to create a collection with a document is as follows −> db.insertOneRecordDemo.insertOne({"UserName":"Larry", "UserAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9534de16f542d757e2b452") } > db.insertOneRecordDemo.insertOne({"UserName":"Chris", "UserAge":26}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9534e816f542d757e2b453") } > db.insertOneRecordDemo.insertOne({"UserName":"David", "UserAge":25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9534f116f542d757e2b454") }Display all documents from a collection ... Read More

Order MySQL Rows with Value Greater Than Zero

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

594 Views

Let us first create a table. Following is the query −mysql> create table gettingAndOrderingRowsDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Value int    -> ); Query OK, 0 rows affected (1.35 sec)Following is the query to insert some records in the table using insert command −mysql> insert into gettingAndOrderingRowsDemo(Value) values(10); Query OK, 1 row affected (0.33 sec) mysql> insert into gettingAndOrderingRowsDemo(Value) values(13); Query OK, 1 row affected (0.32 sec) mysql> insert into gettingAndOrderingRowsDemo(Value) values(0); Query OK, 1 row affected (0.17 sec) mysql> insert into gettingAndOrderingRowsDemo(Value) values(20); Query OK, 1 ... Read More

Keep Insertion Order with Java LinkedHashMap

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

226 Views

To keep the insertion order with LinkedHashMap, use Iterator. Let us first create a HashMap and add elements to it −LinkedHashMaplHashMap = new LinkedHashMap(); lHashMap.put("1", "A"); lHashMap.put("2", "B"); lHashMap.put("3", "C"); lHashMap.put("4", "D"); lHashMap.put("5", "E"); lHashMap.put("6", "F"); lHashMap.put("7", "G"); lHashMap.put("8", "H"); lHashMap.put("9", "I");Now, get the values with the values() method. Iterate through the elements and display them −Collection collection = lHashMap.values(); Iterator i = collection.iterator(); while (i.hasNext()) {    System.out.println(i.next()); }Example Live Demoimport java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; public class Demo {    public static void main(String[] args) {       LinkedHashMaplHashMap = new LinkedHashMap();       lHashMap.put("1", "A");   ... Read More

Create Table with Space in Name in MySQL

Nancy Den
Updated on 30-Jul-2019 22:30:25

4K+ Views

To create a table with a space in the table name in MySQL, you must use backticks otherwise you will get an error.Let us first see what error will arise by creating a table with a space in the name i.e. “Demo Table” table name below:mysql> create table Demo Table (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    EmployeeFirstName varchar(20),    EmployeeLastName varchar(20),    EmployeeAge int,    EmployeeSalary int,    EmployeeAddress varchar(200) ); ERROR 1064 (42000): You have an error in your syntax; check the manual that corresponds to your MySQL server version for the right syntax to ... Read More

Provider toString Method in Java

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

198 Views

The name and the version number of the provider in string form can be obtained using the method toString() in the class java.security.Provider. This method requires no parameters and it returns the name as well as the version number of the provider in string form.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA");          Provider p = kpGenerator.getProvider();          System.out.println("The name and version number of ... Read More

Advertisements