ResultSet Concurrency in JDBC

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

2K+ Views

The concurrency of the ResultSet object determines whether its contents can be updated or not.The Connection interface provides 3 variants of the createStatement() method where one of the method's signature is as follows:Statement createStatement(int resultSetType, int resultSetConcurrency)This method accepts two integer type variables where one represents the type of the ResultSet and the other represents the Concurrency of the ResultSet.The ResultSet interface provides two values to specify the concurrency of the ResultSet.CONCUR_READ_ONLY: If you set this as a value of the concurrency while creating the ResultSet object you cannot update the contents of the ResultSet you can only read/retrieve them.CONCUR_UPDATABLE: ... Read More

LocalDateTime plus Method in Java

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

341 Views

An immutable copy of a LocalDateTime where the required duration is added to it can be obtained using the plus() method in the LocalDateTime class in Java. This method requires two parameters i.e. the duration to be added and the TemporalUnit of the duration. Also, it returns the LocalDateTime object with the required duration added to it.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo {    public static void main(String[] args) {       LocalDateTime ldt = LocalDateTime.now();       System.out.println("The LocalDateTime is: " + ldt);       ... Read More

Write to MongoDB Console in JavaScript Execution

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

118 Views

To write on console, you need to use print() method. The syntax is as follows −print(“yourString”);To display objects, you can use printjson(). The syntax is as follows −printjson(yourObjectName);Let us implement both the functions. The first query is as follows to display something −> print("Welcome to MongoDB Console");The following is the output on a console −Welcome to MongoDB ConsoleLet us create an object. The query is as follows −>studentInformation={"StudentName":"John", "StudentAge":24, "StudentTechnicalSkills":["C", "C++", "Java", "MongoDB", "MySQL"]}; {    "StudentName" : "John",    "StudentAge" : 24,    "StudentTechnicalSkills" : [       "C",       "C++",       "Java",     ... Read More

Use removeFirstOccurrence in Android LinkedBlockingDeque

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

142 Views

Before getting into the example, we should know what LinkedBlockingDeque is. It is implemented by Collection interface and the AbstractQueue class. It provides optional boundaries based on linked nodes. It going to pass memory size to a constructor and helps to provide memory wastage in android.This example demonstrates about How to use removeFirstOccurrence() in android LinkedBlockingDequeStep 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 a ... Read More

MySQL Query to Find Sum of Fields with Same Column Value

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

785 Views

Use GROUP BY clause for this. Let us first create a table −mysql> create table sumOfFieldsDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientSerialNumber varchar(100),    -> ClientCost int    -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to insert some records in the table using insert command −mysql> insert into sumOfFieldsDemo(ClientSerialNumber, ClientCost) values('1111', 450); Query OK, 1 row affected (0.16 sec) mysql> insert into sumOfFieldsDemo(ClientSerialNumber, ClientCost) values('2222', 550); Query OK, 1 row affected (0.15 sec) mysql> insert into sumOfFieldsDemo(ClientSerialNumber, ClientCost) values('3333', 150); Query OK, 1 row affected (0.64 ... Read More

Format Date as Apr 14, 2019 01:35 PM IST in Java

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

118 Views

To format and display datetime, you need to use DateTimeFormatter and use the pattern as:DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z");Above, the z is the timezone:MMM dd yyyy hh:mm a zNow, use the following for zone:ZonedDateTime dateTime = ZonedDateTime.now();Exampleimport java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] argv) {       DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z");       ZonedDateTime dateTime = ZonedDateTime.now();       String res = dateTime.format(dtFormat);       System.out.printf("Date = %s %n", res);    } }OutputDate = Apr 14 2019 01:35 PM IST

Querying Average Row Length in MySQL

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

1K+ Views

You can use INFORMATION_SCHEMA.TABLES and AVG_ROW_LENGTH to query average row length in MySQL −SELECT AVG_ROW_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ‘yourTableName’;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100) ); Query OK, 0 rows affected (0.90 sec)Insert records in the table using insert command −mysql> insert into DemoTable(StudentName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(StudentName) values('Larry'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, ... Read More

MySQL Case Insensitive Distinct

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

5K+ Views

If you want case-insensitive distinct, you need to use UPPER() or LOWER().Case 1: Using UPPER().The syntax is as follows:SELECT DISTINCT UPPER(yourColumnName) FROM yourTableName;Case 2: Using LOWER().The syntax is as follows:SELECT DISTINCT LOWER(yourColumnName) FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table CaseInsensitiveDistinctDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserEmailId varchar(30), -> UserPassword varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.64 sec)Now you ... Read More

DoubleBuffer compareTo Method in Java

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

157 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.DoubleBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          DoubleBuffer buffer1 = DoubleBuffer.allocate(n);     ... Read More

ADSL Protocol Stacks

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

1K+ Views

Asymmetric Digital Subscriber Line (ADSL) is a type of broadband communications technology that transmits digital data at a high bandwidth over existing phone lines to homes and businesses.ADSL protocol stack depicts the set of protocols and devices that are used along with ADSL.In order to access ADSL, a Digital Subscriber Line modem (DSL modem) is installed at the customer site. The DSL modem sends data bits over the local loop of the telephone network. The local loop is a two − wire connection between the subscriber’s house and the end office of the telephone company. The data bits are accepted ... Read More

Advertisements