Add Column with NOT NULL Default Value in MySQL

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

1K+ Views

For this, you need to remove the default keyword. The syntax is as follows:ALTER TABLE yourTableName ADD COLUMN yourColumnName dataType NOT NULL AFTER yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table AddingColumnDefaultValueNOTNULL    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> FirstName varchar(20),    -> LastName varchar(20),    -> Age int,    -> Address varchar(100),    -> Salary int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.58 sec)Now check the description of table. The query is as follows:mysql> desc ... Read More

ShortBuffer equals Method in Java

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

143 Views

The equality of two buffers can be checked using the method equals() in the class java.nio.ShortBuffer. Two buffers are equal if they have the same type of elements, the same number of elements and same sequence of elements. The method equals() returns true if the buffers are equal and false otherwise.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 {          ShortBuffer buffer1 = ShortBuffer.allocate(n);          buffer1.put((short)12); ... Read More

Compatibility Check with 8085AH in 8085 Microprocessor

Chandu yadav
Updated on 30-Jul-2019 22:30:25

299 Views

Let’s perform the memory compatibility check with respect to tAD, tLDR, and tRD parameters.Compatibility with respect to tAD: The time interval between valid address on the addresses ranging from A15 to A0 and valid data on the addresses ranges from AD7 to AD0. For 8085AH the T state working is 320 nS, but it consists of a maximum of 575 nS. But here the valid data is available for 365 nS. So the speed of the memory is compatible, with an excess time margin of 575 nS - 365 nS = 210 nS.Compatibility with respect to tLDR: The time interval between the edge of ... Read More

Get Current Location in Android Web View

Nitya Raut
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrate about How to get current location in android web view.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 web view to show mylocation.org.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ProgressDialog; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @RequiresApi(api = Build.VERSION_CODES.P)    @Override ... Read More

Batch Updates in JDBC Explained

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

1K+ Views

Grouping a set of INSERT or, UPDATE or, DELETE commands (those produce update count value) and execute them at once this mechanism is known as a batch update.Adding statements to the batchThe statement, PreparedStatement, and CallableStatement objects hold a list (of commands) to which you can add related statements (those return update count value) using the addBatch() method.stmt.addBatch(insert1); stmt.addBatch(insert2); stmt.addBatch(insert3);Executing the batchAfter adding the required statements, you can execute a batch using the executeBatch() method of the Statement interface.stmt.executeBatch();Using batch updates, we can reduce the communication overhead and increase the performance of our Java application.Note: Before adding statements to the ... Read More

LocalDateTime isEqual Method in Java

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

132 Views

It can be checked if two LocalDateTime objects are equal or not using the isEqual() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the LocalDateTime object that is to be compared. It returns true if the two LocalDateTime objects are equal and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDateTime ldt1 = LocalDateTime.parse("2019-02-18T23:15:30");       LocalDateTime ldt2 = LocalDateTime.parse("2019-02-18T23:15:30");       System.out.println("The LocalDateTime ldt1 is: " + ldt1);       System.out.println("The ... Read More

LongStream Iterator Method in Java

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

161 Views

The iterator() method of the LongStream class in Java returns an iterator for the elements of this stream.The syntax is as follows.PrimitiveIterator.OfLong iterator()Here, PrimitiveIterator is an Iterator specialized for long values.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;The following is an example to implement LongStream iterator() method in Java.Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.of(15000L, 17000L, 25000L);       PrimitiveIterator.OfLong i = longStream.iterator();       while (i.hasNext()) {          System.out.println(i.nextLong());       }   ... Read More

Call Existing Stored Procedure in Database Using JDBC API

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

877 Views

A. Stored procedures are sub routines, segment of SQL statements which are stored in SQL catalog. All the applications that can access Relational databases (Java, Python, PHP etc.), can access stored procedures.Stored procedures contain IN and OUT parameters or both. They may return result sets in case you use SELECT statements. Stored procedures can return multiple result sets.You can call a stored procedure using the following syntax:CALL procedure_name ()JDBC provides a standard stored procedure SQL escape syntax using which you can procedures in all RDBMSsTo call a stored procedure using a JDBC program you need to:Register the driver: Register the ... Read More

fread Function in C++

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

504 Views

The C/C++ library function size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) reads data from the given stream into the array pointed to, by ptr. Following is the declaration for fread() function.size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)The Following table contains the fread() parameters and description:ParametersDescriptionptrThis is the pointer to a block of memory with a minimum size of size*nmemb bytes.sizeThis is the size in bytes of each element to be read.nmembThis is the number of elements, each one with a size of size bytes.streamThis is the pointer to a FILE object that specifies an input stream.The ... Read More

Use retainAll in Android CopyOnWriteArraySet

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

113 Views

Before getting into an example, we should know what CopyOnWriteArraySet is. It is a thread-safe variant of ArrayList and operations add, set, and so on by making a fresh copy of the underlying array.This example demonstrates about How to use retainAll() in android CopyOnWriteArraySetStep 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 text view to show CopyOnWriteArraySet elements.Step 3 − Add the following code ... Read More

Advertisements