JDBC Example for Inserting BLOB Data into a Table

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

3K+ Views

Assume we already have a table named MyTable in the database with the following description.+-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | Name | varchar(255) | YES | | NULL | | | image | blob | YES | | NULL | | +-------+--------------+------+-----+---------+-------+If you need to ... Read More

LocalDateTime withYear Method in Java

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

125 Views

An immutable copy of a LocalDateTime with the year altered as required is done using the method withYear() in the LocalDateTime class in Java. This method requires a single parameter i.e. the year that is to be set in the LocalDateTime and it returns the LocalDateTime with the year altered as required.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"); System.out.println("The LocalDateTime is: " + ldt1); ... Read More

LongStream sorted() Method in Java

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

120 Views

The sorted() method of the LongStream class in Java returns a stream with the elements of this stream in sorted order.The syntax is as follows −LongStream sorted()To use the LongStream class in Java, import the following package −import java.util.stream.LongStream;Create a LongStream and add some elements −LongStream longStream = LongStream.of(80L, 35L, 15L, 70L, 30L, 45L);Now, sort the elements of the stream −longStream.sorted() The following is an example to implement LongStream sorted() method in Java −Example Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(80L, ... Read More

Find by Multiple Array Items Using $in in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

173 Views

You can use $in operator to find with multiple array items. To understand the concept, let us create a collection with the document.The query to create a collection with a document is as follows −>db.findByMultipleArrayDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Smith",    "StudentCoreSubject":["Compiler", "Operating System", "Computer Networks"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7ef07b559dd2396bcfbfc4") } >db.findByMultipleArrayDemo.insertOne({"StudentFirstName":"Carol", "StudentLastName":"Taylor",    "StudentCoreSubject":["MongoDB", "MySQL", "SQL Server"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7ef09d559dd2396bcfbfc5") } >db.findByMultipleArrayDemo.insertOne({"StudentFirstName":"Bob", "StudentLastName":"Taylor",    "StudentCoreSubject":["MongoDB", "MySQL", "SQL Server"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7ef0c7559dd2396bcfbfc6") } >db.findByMultipleArrayDemo.insertOne({"StudentFirstName":"David", "StudentLastName":"Johnson",    "StudentCoreSubject":["Compiler", "Operating System", "Computer Networks"]}); {    "acknowledged" : true,   ... Read More

Exclude Certain Columns from SHOW COLUMNS in MySQL

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

362 Views

Let us first create a demo tablemysql> create table excludeCertainColumnsDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(100),    -> StudentAge int,    -> StudentMarks int,    -> StudentAddress varchar(200)    -> ); Query OK, 0 rows affected (0.50 sec)Now you can check the description of table with the help of desc command. The query is as follows −mysql> desc excludeCertainColumnsDemo;The following is the output+----------------+--------------+------+-----+---------+----------------+ | Field          | Type         | Null | Key | Default | Extra          | +----------------+--------------+------+-----+---------+----------------+ | ... Read More

Detect When an Android App Goes to Background and Comes Back to Foreground

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

1K+ Views

This example demonstrate about How to detect when an Android app goes to the background and come back to the foregroundStep 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. ss     In the above code, we have taken text view to show an application status.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.widget.TextView; import java.util.List; public class MainActivity extends FragmentActivity ... Read More

Modify a Const Variable in C

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

6K+ Views

In C or C++, we can use the constant variables. The constant variable values cannot be changed after its initialization. In this section we will see how to change the value of some constant variables.If we want to change the value of constant variable, it will generate compile time error. Please check the following code to get the better idea.Example#include main() {    const int x = 10; //define constant int    printf("x = %d", x);    x = 15; //trying to update constant value    printf("x = %d", x); }Output[Error] assignment of read-only variable 'x'So this is generating ... Read More

Variable Scoping in C

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

101 Views

Here we will see how the C variables are scoped. The variables are always statically scoped in C. Binding of a variable, can be determined by the program text. These are independent of runtime function call stack.Let us see one example to get the idea.Example# include int x = 0; int my_function() {    return x; } int my_function2() {    int x = 1;    return my_function(); } int main(){    printf("The value is: %d", my_function2()); }OutputThe value is: 0Here the result is 0. Because the value returned by my_function() is not depends on the function, which is ... Read More

8085 Program to Find Nth Power of a Number

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

795 Views

In this program we will see how to find nth power of a number.Problem StatementWrite 8085 Assembly language program to find nth power of a number. The base is stored at location 8000H, and the exponent is stored at 8001H. Store the result at 8002H.DiscussionIn 8085, we cannot perform the multiplication operation directly. Here we are writing a subroutine to perform the multiplication by using repetitive addition. To perform nth power of a number, we have to multiply the number n times. The n value is used as a counter. If the base is 03H, exponent is 05H, then the ... Read More

Use Gravity View for Android

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

380 Views

Before getting into an example, we should know what gravity view in android is. Gravity view allows us to utilize the motion sensors of an Android device and allow the end user to explore the product by rotating his device.This example demonstrates How to use Gravity View for Android.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 − Open build.gradle and add design support library dependency.apply plugin: 'com.android.application' android {    packagingOptions {       exclude 'META-INF/proguard/androidx-annotations.pro'    }    packagingOptions ... Read More

Advertisements